A while back I created a 32-bit, dialog-based program in Visual Studio 9. Recently I needed to create a 64-bit version. So I went to the Configuration Manager, selected "<new...>", chose "x64" from the "Type" and "Win32" from the "Copy settings from". This has worked just fine to create 64-bit versions for other, similar programs, so I didn't see any problem.
But for this one program, this doesn't work. If I run the program as Win32, then the CWinApp constructor in appcore.cpp is called first, and then the function AfxWinMain() in winmain.cpp. The program runs fine.
If I select the "x64" type, then for some reason the CWinApp constructor is skipped and AfxWinMain() is called first. This means that AfxGetThread() returns NULL, so I get a null pointer exception at the line:
if (!pThread->InitInstance())
Eventually I found from another article on here that going to the Properties page, going to C/C++ -> Preprocessor -> Preprocessor Definitions, and changing "_WINDOWS" to "_CONSOLE" for the x64 platform makes it work.
So my questions would be: why did this happen for this one program, and not others which are written similarly that have been converted to x64; and why did choosing _CONSOLE fix this?