
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
How to determine whether C++ code has been compiled in 32 or 64 bit?
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
- Related Articles
- How to find out linux operating system system is 32 bit or 64 bit
- Difference between 32-bit and 64-bit Operating Systems
- Differentiate between 32-Bit vs. 64-Bit Operating System.
- How to compile 32-bit program on 64- bit gcc in C and C++
- Compile 32-bit program on 64-bit gcc in C and C++
- Python Pandas - Check whether the DateOffset value has been normalized or not
- Python Pandas - Check whether the BusinessDay Offset has been normalized or not
- Python Pandas - Check whether the BusinessHour Offset has been normalized or not
- Python Pandas - Check whether the CustomBusinessDay Offset has been normalized or not
- Python Pandas - Check whether the CustomBusinessHour Offset has been normalized or not
- How to determine if an activity has been called by a Notification in Android?
- Determine whether input has masked values
- 32-bit microprocessors
- Is PHP compiled or interpreted?
- ConvertDecimal to equivalent 32-bit unsigned integer in C#

Advertisements