This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: stdargs x86-64 question
- From: "Luca Béla Palkovics" <luca dot bela dot palkovics at gmail dot com>
- To: phi benard <phi dot benard at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 16 May 2010 11:49:38 +0200
- Subject: Re: stdargs x86-64 question
- References: <AANLkTimc9U7J4MngOK8iTjx6uUm3CKYNJhsdKgAY9vFA@mail.gmail.com>
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.