How can I detect if I'm compiling for a 64bits architecture in C++

前端 未结 8 1703
难免孤独
难免孤独 2020-12-29 23:07

In a C++ function I need the compiler to choose a different block if it is compiling for a 64 bit architecture.

I know a way to do it for MSVC++ and g++, so I\'ll po

8条回答
  •  自闭症患者
    2020-12-29 23:09

    This works for MSVC++ and g++:

    #if defined(_M_X64) || defined(__amd64__)
      // code...
    #endif
    

提交回复
热议问题