Linux 64bit preprocessors
Is there a preprocessor definition I can '#ifdef' to check if the code is compiling 64bit? (like in windows -> 'WIN32' || 'WIN64')
That's OS specific. The Windows headers for MinGW likely define WIN32/WIN64. There is no such thing on GNU/Linux systems, AFAIK (where it wouldn't make much sense anyway: running "Linux64" tells you nothing about the integer size used by the C compiler, endianness, etc.)
cpp -dM /dev/null | less will give you a list of what is available for your platform.
cpp -dM /dev/null | less will give you a list of what is available for your platform.
Maybe this link is interesting:
http://predef.sourceforge.net/prearch.html#sec7
http://predef.sourceforge.net/prearch.html#sec7
Quote: Original post by nmi
Maybe this link is interesting:
http://predef.sourceforge.net/prearch.html#sec7
I think that particular section is for the Itanium family. x86-64 likely falls under AMD64.
Quote: Original post by Null and VoidQuote: Original post by nmi
Maybe this link is interesting:
http://predef.sourceforge.net/prearch.html#sec7
I think that particular section is for the Itanium family. x86-64 likely falls under AMD64.
Ups, thx for noticing that.
Most not yet all unixs use the LP64 model, so a check for the define __LP64__ or _LP64 should catch most of the them. LP64 data model defines the following:
edit:
So a combination of all of these methods should catch the it.
[Edited by - dmail on March 25, 2008 10:43:45 AM]
Quote:
...long int and pointer both use 64-bits and int uses 32-bit.
edit:
So a combination of all of these methods should catch the it.
#ifdef __GNUC__# if defined __LP64__ || defined _LP64# define SYSTEM_BITS 64# elif defined __x86_64__ || defined __ia64__ || defined_IA64 || defined__IA64__ || defined __amd64__ || defined __amd64 || defined __x86_64__ || defined __x86_64 # define SYSTEM_BITS 64#else# define SYSTEM_BITS 32 extern char dummy_bit_checker[(sizeof(long) == sizeof(void*) == 4) ? 1 :-1];#endif
[Edited by - dmail on March 25, 2008 10:43:45 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement