stdargs x86-64 question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I am new at using gcc and I bump into something that prevent a application port.

I am doing something along those lines

OS   :
CX48$ uname -a
Linux hpfrcx48 2.6.26-2-amd64 #1 SMP Thu Feb 11 00:59:32 UTC 2010 x86_64 GNU/Lin
ux

GCC :
CX48$ gcc --version
gcc (Debian 4.3.2-1.1) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

.c:

#include <stdarg.h>

int f(char *fmt,...)
{ va_list ap;
  int i;
  long l;

  va_start(ap,fmt);

  if(fmt[0]=='i')
  { i=va_arg(ap,int);
    printf("i=0x%08lx\n",i);
  }
  if(fmt[0]=='l')
  { l=va_arg(ap,long);
    printf("l=0x%016x\n",l);
  }

}


main()
{ f("i",0x04030201);
  f("l",0x0102030405060708L);
}

execution:
CX48$ ./c
i=0x04030201
l=0x0000000005060708 <<======= ????

What am I doing wrong here?
On other OS/Architectures I got 0x0102030405060708

Thanx in advance for your advises.
Cheers,
Phi

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux