When we add a 64bit configuration from a 32bit project that has already existed, Visual Studio copies the 32bit configurations by default. VS even copies _WIN32
All my 64bit projects define also _WIN32 now, despite the开发者_Python百科y(64bit PEs) never can run on 32bit Windows. It is very uncomfortable to me.I'd like to remove the _WIN32 if it doesn't have any problem. I'm not sure about that.
Is it okay if I remove the _WIN32 definition?_WIN32 doesn't mean what you think it does. It means "I am using the Windows API". The 32 postfix was added back in the days of Windows NT 3.1 to make it distinct from the 16-bit API that was used in Windows version 3. This term has fallen out of favor because of the bitness problem. You can see this at stackoverflow.com, the [win32] tag takes you to [winapi].
Don't remove it, you are using the Windows API.
The documentation for the predefined macros says:
_WIN32: Defined for applications for Win32 and Win64. Always defined.
_WIN64: Defined for applications for Win64.
So not only should _WIN32
always be defined, it does not cause any problem in 64-bit applications. Therefore, I'd suggest you don't remove it.
You should never define either of them.
The toolchain (compiler + system headers) will define them as appropriate.
_WIN32:Defined for applications for Win32 and Win64. Always defined.
_WIN64:Defined for applications for Win64.
More detail: Predefined Macros .
To put it simply, WIN32/_WIN32 is used to tell whether you are using Windows(For crossing system application), while _WIN64 is used to tell the compiling environment is x86 or x64.
If you want to know whether your application is running under Windows x64, you should use Windows API IsWow64Process .
精彩评论