Reputation: 3
#include <stdio.h>
#include <windows.h>
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
return(0);
}
I'm new to C. The above code returns the following error when I try to compile:
main.c:3:5: error: conflicting types for 'WinMain'
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
^~~~~~~
In file included from c:\mingw\include\windows.h:44:0,
from main.c:2:
c:\mingw\include\winbase.h:1263:14: note: previous declaration of 'WinMain' was here
int APIENTRY WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
Upvotes: 0
Views: 2055
Reputation: 34585
You should make the function definition match the library's declaration. You have
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
and this needs to be
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
It is missing that APIENTRY
.
Upvotes: 2