tags:

views:

619

answers:

2

When running on Leopard you can do something like:

#if __LP64__
   #pragma message ("64 bit Leopard issue")
#endif

What is Snow Leopard and Snow Leopard 64

AND (most importantly)

Where would I have found this answer myself and not had to ask?

+2  A: 

__LP64__ is a gcc preprocessor macro that is nonzero whenever you are building the 64bit data model regardless of the OS X version you are building on. Another macro that will be nonzero is __x86_64__ when building for 64bit Intel processors. You can find more information about these and other macros at developer.apple.com.

You can specify a deployment target for your XCode project, which will specify the minimum permissible OS version on which your application can run. You can leverage this setting in your code to conditionally enable/disable parts of it; see this mailing list post for more info.

fbrereto
Also: [the GCC docs](http://gcc.gnu.org/onlinedocs/gcc-3.4.6/cpp/Common-Predefined-Macros.html)
Chuck
@fbrereto - so should I use 'if X86_64' for 64 bit things and then default to the 32 bit stuff if now? Does LP_64 or X86_64 work on Windows and AMD processors too (my app gets built for both). And if so then I would need something like 'if X86_4' and inside if Apple or WIN32....am I thinking correctly?
JT
@fibrereto - Which looks to me _WIN32 and _WIN64 and for Apple __APPLE__
JT
+1  A: 

__LP64__ is not an abbreviation of "Leopard 64". It stands for "longs and pointers are 64 bits". It is set on SnowLeopard in exactly the same circumstances as it is on Leopard.

__LP64__ will not have the same behavior on windows, because windows uses a different 64-bit model, in which longs are not 64 bits wide. Instead, in 64-bit windows, long is 32 bits wide and long longs and pointers are 64 bits wide. This is commonly referred to as the "llp64" model.

Stephen Canon
@Stephen, So I would do __LP_64__ for OS X and Linux and is there an __ILP_64__ for Windows?
JT
I'm not familiar with the windows build environment; hopefully someone else can tell you what preprocessor symbol to use. However, if Windows did have a macro like that, it would be `__LLP64__`.
Stephen Canon