# How to determine whether C++ code has been compiled in 32 or 64 bit?

C++Server Side ProgrammingProgramming

In C++, there is no direct way to check the environment architecture. There are two Macros for Windows systems, that can be used to check the architecture. These macros are _WIN64, and _WIN32. When the system is 64-bit, then the _WIN64 will be 1, otherwise the _WIN32 will be 1. So using macro checking, we can identify the architecture

## Example

#include <iostream>
using namespace std;
int main() {
#ifdef _WIN64
cout << "This is 64 bit system" << endl;
#elif _WIN32
cout << "This is 32 bit system" << endl;
#endif
}

## Output

This is 64 bit system
Published on 07-May-2019 16:14:58