Ah, OK - "never used" happens to exclude any C++ code I've worked on so far.paulbarker wrote:
It's still valid C++ to use 'struct mmap' but in practice it is never used.
unsigned long long in GCC?
Re:unsigned long long in GCC?
Every good solution is obvious once you've found it.
Re:unsigned long long in GCC?
Almost. In C++, for both classes and structs, the typedef is implicit.Candy wrote: AFAIK, you always need to say:, both in C and C++, since they're based on the same language. For classes this typedef is implicit. At least, that's what I know.Code: Select all
typedef struct { } xyz;
Re:unsigned long long in GCC?
What is the actual line you print this out. what i mean is, is it like this
or this
Code: Select all
printf("%d\n",sizeof(struct asd));
Code: Select all
printf(sizeof(struct asd));
Re:unsigned long long in GCC?
I don't know if this has anything to do with it, but I've seen that some [tt]printf[/tt]s don't support 64-bit integers properly; printing, for example, 0x0000 0000 0000 0014 (20) might produce only the first 32 bits, 0x0000 0000 (0), because [tt]%i[/tt] or [tt]%d[/tt] will only see 32-bit values on the stack. Something similar may be happening with your [tt]printf[/tt]; if any values that follow in the arg list are also borked, then that's my diagnosis.
Hope this helps.
Hope this helps.
Re:unsigned long long in GCC?
*cough*evincarofautumn wrote: ...because [tt]%i[/tt] or [tt]%d[/tt] will only see 32-bit values on the stack.
Of course will %i and %d only see 32-bot-values on the stack. That is why a compliant printf supports %ld and %lld for long and long long...
Every good solution is obvious once you've found it.
- spix
- Member
- Posts: 128
- Joined: Mon Jun 26, 2006 8:41 am
- Location: Millicent, South Australia
- Contact:
Re:unsigned long long in GCC?
I misunderstood this too, what viral is trying to do is print the sizeof a long long which is only 8 bytes and the structure is as someone else mentioned is 20 bytes, so %d will easily handle it.Something similar may be happening with your printf; if any values that follow in the arg list are also borked, then that's my diagnosis.
Re:unsigned long long in GCC?
Yeah, he's printing the size of them, not the values, and if the size couldn't fit in a 32-bit variable then we have slightly more problems
Re:unsigned long long in GCC?
Ya I dont have a structure whos size is more than 4GB.Yeah, he's printing the size of them, not the values, and if the size couldn't fit in a 32-bit variable then we have slightly more problems
Re:unsigned long long in GCC?
I'm guessing you're using the gcc that comes precompiled for your system
What happens if you compile a really simple program in c++, which has the structure definition and a main function which prints the size the struct and does *nothing* else? If that fails, try building your own gcc (maybe even as a cross-compiler - see the osfaq).
If you are using a gcc you build yourself, try rebuilding it and if possible run 'make check' before installing - the c testsuite should catch this sort of problem.
Another trick is to use 'gcc -S' on the source file to get assembly language output, or 'gcc -E' to make sure it isn't a weird pre-processing definition which is ruining the code.
Try printing the size of a packed structure (see the gcc manual).
And try everything else you can think of to isolate what is causing this bug because it is very, very strange.
What happens if you compile a really simple program in c++, which has the structure definition and a main function which prints the size the struct and does *nothing* else? If that fails, try building your own gcc (maybe even as a cross-compiler - see the osfaq).
If you are using a gcc you build yourself, try rebuilding it and if possible run 'make check' before installing - the c testsuite should catch this sort of problem.
Another trick is to use 'gcc -S' on the source file to get assembly language output, or 'gcc -E' to make sure it isn't a weird pre-processing definition which is ruining the code.
Try printing the size of a packed structure (see the gcc manual).
And try everything else you can think of to isolate what is causing this bug because it is very, very strange.
Re:unsigned long long in GCC?
Hi..
Thanks for all those replies....
Now its working nicely as no long long manipulation needed.... I dont see any benifits in wasting time to debug that ugly long long issue.. better I switch to more general format..
Thanks for all those replies....
Ya the bug is really very very strange and thts why I change my code from long long to simple unsigned int.And try everything else you can think of to isolate what is causing this bug because it is very, very strange.
Now its working nicely as no long long manipulation needed.... I dont see any benifits in wasting time to debug that ugly long long issue.. better I switch to more general format..
Re:unsigned long long in GCC?
I sorely misworded that post. ;DYa I dont have a structure whos size is more than 4GB.