本文介绍了WinMain和简单代码的编译错误,"以前的WinMain"解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#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:mingwincludewindows.h:44:0,
                 from main.c:2:
c:mingwincludewinbase.h:1263:14: note: previous declaration of 'WinMain' was here
 int APIENTRY WinMain (HINSTANCE, HINSTANCE, LPSTR, int);

推荐答案

您应该使函数定义与库的声明匹配。您有

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)

这需要

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)

缺少APIENTRY

这篇关于WinMain和简单代码的编译错误,&quot;以前的WinMain&quot;解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-20 05:43