How to fix Win32 error 2731 on WinMain() function cannot be overloaded.

Gary Myers 0 Reputation points
2025-04-22T18:43:09.2933333+00:00

I am writing code for an x86 project in Studio 2022. The code comes from a book on game programming. Everytime I try to compile the program, I get the error message 2731 stating that the WinMain() function cannot be overloaded. My declaration is the following:

int APIENTRY wWinMain(In HINSTANCE hInstance, In_opt HINSTANCE hPrevInstance, In PSTR szCmdLine, In int iCmdShow)

If I leave out the 'I n' I get a linker error instead.

How can I fix this issue?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,912 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Gary Myers 0 Reputation points
    2025-04-23T01:52:03.2966667+00:00

    I was creating a new project and trying to run it as an x86. I forgot to go into the project settings, Linker, System and change from Console subsystem to Windows subsystem. It will run without the annotations as long as everything is declared in the main file.

    0 comments No comments

Your answer