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__
.
Asked
Active
Viewed 5,512 times
2
3 Answers
0
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.

GManNickG
- 494,350
- 52
- 494
- 543
-
Correct me if I'm wrong, but this won't disambiguate between 32-bit and 64-bit Windows, only between MSVC and other compilers (and between MSVC versions). Boost seems overkill if this is the only reason for adding it as a dependency for the project. If it's already being used, well, that's cool too. – mrkj Apr 01 '10 at 18:20
-
1@mrkj: Boost isn't all or nothing. Just grab the necessary header and live free. – GManNickG Apr 01 '10 at 19:05
-1
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?

Pavel Minaev
- 99,783
- 25
- 219
- 289
-
@pavel - This is a cross platform app that runs on OS X, Linux and Windows and moving to 64-bit and some Snow Leopard specific items, The logic would certainly be a lot easier to integrate if there was a preprocessor variable. I could use _Win_32 and _Win_64 I suppose since those wont be defined on OS X where LP64 is... – JT. Nov 18 '09 at 22:01
-
3The reason why I asked is because a lot of conditional compilation logic in C++ doesn't really require a preprocessor - you can creatively use templates to produce typedefs, for example. Or just use some stock things, such as `cstdint` header from Boost (as MSVC doesn't have it), and `intptr_t` when you need an integral type that has the same size as pointer on a given platform. It all depends on what specific cases are there in your code that are bitness-specific. – Pavel Minaev Nov 18 '09 at 22:32
-
on 64-bit Windows `long` is 32 bits while `void*` is 64 bits. The same to [x32-ABI](https://sites.google.com/site/x32abi/) on Unix – phuclv Nov 28 '14 at 06:55