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__
.
views:
309answers:
3
A:
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
2009-11-18 21:59:44
@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
2009-11-18 22:01:52
The 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
2009-11-18 22:32:02
A:
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.
GMan
2009-11-18 22:01:42
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
2010-04-01 18:20:19
@mrkj: Boost isn't all or nothing. Just grab the necessary header and live free.
GMan
2010-04-01 19:05:55