__LP64__ on Windows?

5.7k views Asked by At

I know Windows uses LLP instead of the LP data model, but is there a predefined variable or something? on OS X/Linux you can use __LP64__.

3

There are 3 answers

3
Pavel Minaev On

Do you really need a preprocessor variable (depending on the case, it might be required, but you may also be able to do without)? Is sizeof(long) == sizeof(void*) not good enough?

2
GManNickG On

I don't know if such variable, but you can test for _MSC_VER, which will be defined in Visual Studio. You can then assume an LLP model. If that ever changes in the future, you can use the value of _MSC_VER to test against compiler versions.

If you're looking for standard sized types, check out boost::integer, which defines fixed-bit-sized integer types.

0
mrkj On

One way to check is with _WIN64, which is defined only on 64-bit Windows (see here and here). For example:

#if defined(__LP64__)
// LP64 machine, OS X or Linux
#elif defined(_WIN64)
// LLP64 machine, Windows
#else
// 32-bit machine, Windows or Linux or OS X
#endif