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

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


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