【发布时间】:2021-06-18 12:48:22
【问题描述】:
#include <stdio.h>
#include <windows.h>
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
return(0);
}
我是 C 新手。上面的代码在我尝试编译时返回以下错误:
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);
【问题讨论】:
-
你把上面的代码放在哪里了?它在 main 之上吗?
-
我没有主文件。我需要一个吗?上面的代码是我项目的全部代码。 @AsafItach
-
仍然出现同样的错误。
-
windws.h 是一个头文件,可让您为 Windows 编译程序,根据维基百科,它自动包含定义 HINSTANCE 的 windef.h。手动包含 windef.h 并不能解决错误。