Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I define both _WIN32 and _WIN64 in 64bit build?

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 they(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?

like image 249
Benjamin Avatar asked Jul 13 '11 13:07

Benjamin


People also ask

Is _WIN32 defined for x64?

The symbol _WIN32 is defined by the compiler to indicate that this is a (32bit) Windows compilation. Unfortunately, for historical reasons, it is also defined for 64-bit compilation.

Where is _WIN32 defined?

_WIN32 is automatically defined by the visual C/C++ compiler.


1 Answers

_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.

like image 67
Hans Passant Avatar answered Sep 24 '22 00:09

Hans Passant