Page 2 of 2
Re:unsigned long long in GCC?
Posted: Sun Jul 23, 2006 2:18 am
by Solar
paulbarker wrote:
It's still valid C++ to use 'struct mmap' but in practice it is never used.
Ah, OK - "never used" happens to exclude any C++ code I've worked on so far.
Re:unsigned long long in GCC?
Posted: Sun Jul 23, 2006 9:22 am
by df
why not include stdint.h and use uint64_t ??
Re:unsigned long long in GCC?
Posted: Mon Jul 24, 2006 2:00 am
by bakery2k
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.
Almost. In C++, for both classes and structs, the typedef is implicit.
Re:unsigned long long in GCC?
Posted: Mon Jul 24, 2006 4:37 am
by B.E
What is the actual line you print this out. what i mean is, is it like this
Code: Select all
printf("%d\n",sizeof(struct asd));
or this
Re:unsigned long long in GCC?
Posted: Mon Jul 24, 2006 7:38 pm
by evincarofautumn
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.
Re:unsigned long long in GCC?
Posted: Mon Jul 24, 2006 10:01 pm
by Solar
evincarofautumn wrote:
...because [tt]%i[/tt] or [tt]%d[/tt] will only see 32-bit values on the stack.
*cough*
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...
Re:unsigned long long in GCC?
Posted: Tue Jul 25, 2006 1:21 am
by spix
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.
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.
Re:unsigned long long in GCC?
Posted: Tue Jul 25, 2006 5:56 am
by Kemp
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?
Posted: Tue Jul 25, 2006 8:53 am
by viral
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
Ya I dont have a structure whos size is more than 4GB.
Re:unsigned long long in GCC?
Posted: Tue Jul 25, 2006 9:26 am
by paulbarker
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.
Re:unsigned long long in GCC?
Posted: Tue Jul 25, 2006 11:55 pm
by viral
Hi..
Thanks for all those replies....
And try everything else you can think of to isolate what is causing this bug because it is very, very strange.
Ya the bug is really very very strange and thts why I change my code from long long to simple unsigned int.
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?
Posted: Wed Jul 26, 2006 9:39 am
by evincarofautumn
Ya I dont have a structure whos size is more than 4GB.
I sorely misworded that post. ;D