Domanda

I have been trying to make a WIN32 Application with a GUI (NOT a simple console application) on VS2012, and I'm stuck with this one error. My project is on Release configuration. My main function looks like this:

int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{

    return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);
}

What I've tried:

1) Creating a new WIN32 Project with these settings:

  • Application Type -> Windows application
  • Additional options -> Empty Project (With NO SDL!)
  • No other options checked

2) Changing between Unicode and Multi-Byte Character Sets

3) Changing the SubSystem (from Windows (/SUBSYSTEM:WINDOWS) to Not Set)

4) Adding entry points (main ; _main ; WinMain)

5) Adding #undef _ATL_MIN_CRT (I'm pretty sure it was disabled anyway, but still did it for extra insurance...)

NONE of these solved my issue. I've searched the Internet and haven't found anyone with a similar problem (creating a WIN32 Application) who has solved their issue.

EDIT: I'm also using Allegro 5 library and I'm building the program with /MT .

Any recommendations are welcome.

È stato utile?

Soluzione 2

After some searching I've found the answer.

All I needed to do was to define ALLEGRO_NO_MAGIC_MAIN .

Altri suggerimenti

The problem is that you're using the wrong calling convention for your main function. As the documentation for Name Decoration explains, a symbol with a leading underscore and no other decorations indicates C calling convention.

The signature for your main function should be:

extern "C" __cdecl void main();

Note that neither the return value nor the argument list are part of the name decoration, since the caller is responsible for cleanup. This means that any function signature can be used to satisfy the linker.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top