views:

41

answers:

2

I want to write code that compiles easily for either 32 or 64 bit linux under gcc. I guess I'm looking for something like

#ifdef IA32
subl $0x4, %esp
#endif

#ifdef X86_64
subl $0x4, %rsp
#endif
+2  A: 

Most likely what you're looking for is _LP64, which is defined when pointer size is 64-bit wide

Rom
+1  A: 

I believe the following should work:

#if defined __i386__
subl $0x4, %esp
#elif defined __x86_64__
subq $0x4, %rsp
#else
#error Unknown architecture!
#endif

Fixed the suffix on sub in the 64-bit code for you, too =)

Stephen Canon