unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

I'm trying to build this program:

(From Programming Windows Fifth Edition)

// Displays screen size in a message box

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

int CDECL MessageBoxPrintf( TCHAR * szCaption, TCHAR * szFormat, ... )
{
TCHAR szBuffer[ 1024 ];
va_list pArgList;

// The va_start macro (defined in STDARG.H) is usually equivalent to:
// pArgList = (char *) &szFormat + sizeof( szFormat );

va_start( pArgList, szFormat );

// The last argument to wvsprintf points to the arguments

_vsntprintf( szBuffer, sizeof( szBuffer ) / sizeof( TCHAR ), szFormat, pArgList );

// The va_end macro just zeroes out pArgList for no good reason

va_end( pArgList );

return MessageBox( NULL, szBuffer, szCaption, 0 );
}

------------------------------------------------------------------------------

When I compile, I get the error "unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup". I've been searching online for help, and it says to change the Linker's Entry Point to "wWinMainCRTStartup", but when I do this I still get the exact same error as before. Am I doing something wrong?
If that is your entire program, then yes, you are missing the main entry point for the program. You are trying to complie a GUI application, so you are required to provide a WinMain() function. If you were creating a console application, you would be required to provide a main() function.

If you are using Visual Studio, just start over: Create a new Win32 Project, then select from the settings that you want an empty console application, then add a single CPP file, add the above code and finally add a int main() function.
Oh wow...that should have been so obvious. Thanks! My program works now.
Topic archived. No new replies allowed.