Is there a standard way to determine at compile-time if system is 32 or 64 bit?

The only compile check you can do reliably would be sizeof(void*) == 8, true for x64 and false for x86. This is a constexpr and you can pass it to templates but you can forget using ifdef with it. There is no platform-independent way to know the address size of the target architecture (at pre-process time), you will need to ask your IDE for one. The Standard doesn't even have the concept of the address size.


No there is no standard language support for macro to determine if the machine is a 64-bit or 32-bit at preprocessor stage.


In response to your edit, there is a "macro-less for you" way to get a type that is 64 bits.

if you need a type that can hold 64 bits, then #include <cstdint> and use either int64_t or uint64_t. You can also use the Standard Integer Types provided by Boost.

Another option is to use long long. It's technically not part of the C++ standard (it will be in C++0x) but is supported on just about every compiler.