GCC detect 32 or 64 bit system

For example:

#include <iostream>

#if __x86_64__
#define ENV64BIT
#else
#define ENV32BIT
#endif

using namespace std;

int main() {

  #ifdef ENV64BIT
  cout << "64 bit" << endl;
  #endif

  #ifdef ENV32BIT
  cout << "32 bit" << endl;
  #endif
}
 

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>