How to check the system is 32 vs 64 bit in C



Unfortunately there is no cross platform macro which defines 32 / 64 bit across the major compilers. I've found the most effective way to do this is the following.

First I pick my own representation. I prefer ENVIRONMENT64 / ENVIRONMENT32. Then I find out what all of the major compilers use for determining if it's a 64 bit environment or not and use that to set my variables.

// Check windows  #if _WIN32 || _WIN64  #if _WIN64  #define ENVIRONMENT64  #else  #define ENVIRONMENT32  

Comments

Popular Posts