_AMD64_ is not defined in VS2010

I created a new C ++ project in VS2010. I added x64 as a new solution platform. I tried setting the "copy settings from" to "Win32" and "empty", but it did not work. _AMD64_ not detected when I select x64 as the platform. Shouldn't it be? Is there another step that I do not know for compiling for 64-bit?

Waiting for questions: I am using VS2010 Ultimate, the Windows 7 64bit, x64 compilers were selected during the VS installation.

+4
source share
1 answer

You are all right. The _AMD64_ is not set by default in Visual Studio. You will need to define it yourself if you want to use it:

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

But you do not make up the memory of its existence. The Windows DDK comes with makefiles that define this character, in addition to some others. Check makefile.def . The following options are possible:

  • _X86_
    Differently known as x86, i386 and IA-32
    (this is the same as VS predefined _M_IX86 )

  • _AMD64_
    Known as AMD64, x64, x86-64, IA-32e, and Intel 64
    (this is the same as VS predefined _M_X64 and _M_AMD64 )

  • _IA64_
    Intel Itanium (IA-64)
    (this is the same as the predefined VS _M_IA64 )

  • & hellip; and some others for architectures that no one else targets

Ideally, you should configure the build system to predefine a set of well-known macros that will then be used in your own code. If you don't have a build system, at least install something in a precompiled header file. Thus, you do not rely on implementation-specific characters, and switching compilers is not a colossal chorus - the symbols of the target architecture, predefined by GCC, are very different from MSVC, for example.

+5
source

All Articles