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
Is there a #define for 64 bit in Visual 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 Daniel A. White
Use _WIN64
. It won't matter the type of 64 bit processor.
使用_WIN64
. 64 位处理器的类型无关紧要。
回答by Anand Paul
#ifdef WIN32
or #ifdef _WIN32
will work in x64.
#ifdef WIN32
或#ifdef _WIN32
将在 x64 中工作。