Reputation: 22011
/** converts 'WinMain' to the traditional 'main' entrypoint **/
#define PRO_MAIN(argc, argv)\
int __main (int, LPWSTR*, HINSTANCE, int);\
int WINAPI WinMain (HINSTANCE __hInstance, HINSTANCE __hPrevInstance, \
LPSTR __szCmdLine, int __nCmdShow)\
{\
int nArgs;\
LPWSTR* szArgvW = CommandLineToArgvW (GetCommandLineW(), &nArgs);\
assert (szArgvW != NULL);\
return __main (nArgs, szArgvW, __hInstance, __nCmdShow);\
}\
\
int __main (int __argc, LPWSTR* __argv, HINSTANCE __hInstance, int __nCmdShow)
Now, when I use this code here:
PRO_MAIN(argc, argv)
{
...
}
I get the error:
error: conflicting types for '__main'
note: previous declaration of '__main' was here
What's the problem?
Upvotes: 3
Views: 1260
Reputation: 503855
You have broken the rules: double-underscores are reserved for implementation! (Among other things.)
You simply cannot use __main
, main__
, _Main
, etc. You should pick something else.
I would recommend you make this work:
int main(int argc, char* argv[])
{
// main like normal
}
// defines WinMain, eventually makes call to main()
PRO_MAIN;
Which has the added advantage that for non-Windows applications, PRO_MAIN
can simply expand to nothing, and the program still compiles with the standard main function. This is what I do.
Upvotes: 4