This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stdargs x86-64 question


Am Sonntag, den 16.05.2010, 10:44 +0200 schrieb phi benard:

> execution:
> CX48$ ./c
> i=0x04030201
> l=0x0000000005060708 <<======= ????
> 
> What am I doing wrong here?
> On other OS/Architectures I got 0x0102030405060708

Are you sure that %x takes 64bit numbers ?
maybe %lx works..

> { i=va_arg(ap,int);
>     printf("i=0x%08lx\n",i);
>   }
Here you use 0x08lx ...

> { l=va_arg(ap,long);
>     printf("l=0x%016x\n",l);
>   }
Here you use 0x016x .. try 0x016lx

l for long .. but ! on a 32bit system it's 32bits long !
so you would need to use ll for long long.. 

http://en.wikipedia.org/wiki/64-bit -> "Specific C-language data models"

Luca. 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]