

- Photozoom pro 7.02 installation et portable x86 x64 code#
- Photozoom pro 7.02 installation et portable x86 x64 windows#
Then you can use it like: #if MYPROJ_IS_BITNESS( 64 ) Static_assert( sizeof( void* ) = 4, "Pointer size is unexpected for this bitness" ) # define MYPROJ_IS_BITNESS_PRIVATE_DEFINITION_32() 1 # define MYPROJ_IS_BITNESS_PRIVATE_DEFINITION_64() 0 Static_assert( sizeof( void* ) = 8, "Pointer size is unexpected for this bitness" ) # define MYPROJ_IS_BITNESS_PRIVATE_DEFINITION_32() 0 # define MYPROJ_IS_BITNESS_PRIVATE_DEFINITION_64() 1 #define MYPROJ_IS_BITNESS( X ) MYPROJ_IS_BITNESS_PRIVATE_DEFINITION_#X() I used this technique (among many others) to write a 30,000 line project that worked flawlessly from the day it was first deployed into production (that was 12 months ago).īorrowing from Contango's excellent answer above and combining it with " Better Macros, Better Flags" from Fluent C++, you can do: // Macro for checking bitness (safer macros borrowed from The reason why this works well is that it forces you to think of every single case in advance, and not rely on (sometimes flawed) logic in the "else" part to execute the correct code. Every switch() statement ends in a "default:" which generates a warning or error.Every if() statement ends in an "else" which generates a warning or error.Incidentially, the rules above can be adapted to make your entire codebase more reliable: The run-time check to compile-time one using static assert:

#error "Must define either ENV32BIT or ENV64BIT"Ĭomment from years later (don't know if it was possible before) you can convert I'm only human, and the mistakes above would break the *entire* codebase. - What if there is an unknown unknown, not mentioned in this list so far?
Photozoom pro 7.02 installation et portable x86 x64 code#
- What if the code has just been ported to a different OS? (in Windows, both are defined in 64-bit, so this will break codebase) - What if I checked for _WIN32 first instead of second? - What if I didn't include the required header file? - What if project is corrupted, and _WIN64 and _WIN32 are not defined? - What if both ENV64BIT and ENV32BIT are not defined? - What if I made a typo and checked for ENV6BIT instead of ENV64BIT? The general rule is "every #define must end in a #else which generates an error". Simple check 3/3: Robust compile time checking #error "Must define either ENV32BIT or ENV64BIT". Wprintf(L"Diagnostics: we are running in 32-bit mode.\n") Wprintf(L"ENV32BIT: Error: pointer should be 4 bytes. Wprintf(L"Diagnostics: we are running in 64-bit mode.\n") Wprintf(L"ENV64BIT: Error: pointer should be 8 bytes. In main(), double check to see if sizeof() makes sense: #if defined(ENV64BIT)
Photozoom pro 7.02 installation et portable x86 x64 windows#
I suggest the method from // Check windows Therefore, the only reliable method is to combine 3 simple checks:Ĭhoose any method to set the required #define variable. This makes it difficult to see exactly which #define is being used at compile time. On Visual Studio 2008 SP1, sometimes the intellisense does not grey out the correct parts of the code, according to the current #define.A project labelled "Win32" could be set to 64-bit, due to a project configuration error.Both _WIN32 and _WIN64 can sometimes both be undefined, if the project settings are flawed or corrupted (particularly on Visual Studio 2008 SP1).

Unfortunately, in a cross platform, cross compiler environment, there is no single reliable method to do this purely at compile time.
