C++ Visual Studio 2010 中是否有针对 64 位的 #define?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8672887/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 18:57:13  来源:igfitidea点击:

Is there a #define for 64 bit in Visual Studio 2010?

c++cvisual-studio-2010

提问by nathan

Is there a #define that indicates whether Visual Studio is compiling in 64bit mode? I'd like to be able to include some code conditionally like so

是否有 #define 指示 Visual Studio 是否在 64 位模式下编译?我希望能够像这样有条件地包含一些代码

#ifdef _IS_64BIT
  ...
#else //32 bit
  ...
#endif

I know I can create a flag myself, but I'm wondering if the compiler provides one.

我知道我可以自己创建一个标志,但我想知道编译器是否提供了一个标志。

回答by Niklas B.

#ifdef _WIN64
  ...
#else
  ...
#endif

Documented on MSDN

记录在MSDN 上

回答by Daniel A. White

Use _WIN64. It won't matter the type of 64 bit processor.

使用_WIN64. 64 位处理器的类型无关紧要。

回答by Anand Paul

#ifdef WIN32or #ifdef _WIN32will work in x64.

#ifdef WIN32#ifdef _WIN32将在 x64 中工作。