_AMD64_ 未在 VS2010 中定义 [英] _AMD64_ not defined in VS2010

查看:33
本文介绍了_AMD64_ 未在 VS2010 中定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 VS2010 中创建了一个新的 C++ 项目.我添加了 x64 作为新的解决方案平台.我尝试将复制设置"设置为Win32"和空",但都没有奏效.当我选择 x64 作为平台时,_AMD64_ 未定义.不应该吗?对于 64 位编译,还有我不知道的步骤吗?

I created a new c++ project in VS2010. I added x64 as a new solution platform. I tried setting "copy settings from" to both "Win32" and "empty", but neither worked. _AMD64_ is not defined when I select x64 as the platform. Shouldn't it be? Is there another step I am unaware of for compiling for 64 bit?

预期问题:我使用的是 VS2010 Ultimate,在 VS 安装过程中选择了 Windows 7 64 位、x64 编译器.

In anticipation to questions: I am using VS2010 Ultimate, Windows 7 64bit, x64 compilers were selected during VS installation.

推荐答案

您已正确完成所有步骤._AMD64_ 符号 不是 Visual Studio 默认预定义的.如果你想使用它,你需要自己定义它:

You've got all the steps right. An _AMD64_ symbol is not predefined by default by Visual Studio. You'll need to define it yourself if you want to use it:

#if defined _M_X64 || defined _M_AMD64
    #define _AMD64_
#endif

但你并不是在回忆它的存在.除了一些其他符号之外,Windows DDK 还附带定义此符号的 makefile.签入makefile.def.可能性是:

But you're not making up the memory of its existence. The Windows DDK comes with makefiles that define this symbol, in addition to some others. Check in makefile.def. The possibilities are:

  • _X86_
    被称为 x86、i386 和 IA-32
    (这个和VS预定义的_M_IX86一样)

_AMD64_
也称为 AMD64、x64、x86-64、IA-32e 和 Intel 64
(这与VS预定义的_M_X64_M_AMD64相同)

_IA64_
英特尔安腾 (IA-64)
(这个和VS预定义的_M_IA64一样)

…还有一些其他人不再针对的架构

…and some others for architectures nobody targets anymore

理想情况下,您可以配置构建系统以预定义一组已知的宏,然后您将在自己的代码中使用这些宏.如果您没有构建系统,请至少在预编译的头文件中设置一些内容.这样,您就不会依赖无处不在依赖于实现的符号,并且切换编译器也不是一件大事——例如,GCC 预定义的目标架构符号与 MSVC 非常不同.

Ideally, you would configure your build system to predefine a set of known macros that you will then use in your own code. If you don't have a build system, at least set something up in a precompiled header file. That way, you're not relying on implementation-dependent symbols everywhere, and switching compilers is not a colossal chore—the target architecture symbols predefined by GCC are very different from MSVC, for example.

这篇关于_AMD64_ 未在 VS2010 中定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆