Eclipse 给出错误"无法解析函数'MessageBoxA'",但仍然成功编译?

Eclipse gives an error 'Function 'MessageBoxA' could not be resolved' but still compiles successfully?

本文关键字:成功 编译 MessageBoxA 函数 出错 Eclipse 错误      更新时间:2023-10-16

使用MinGW工具链(和Internal Builder)在eclipse上编译Win32应用程序时,eclipse编译以下代码:

#include <windows.h>
int WinMain (HINSTANCE p1, HINSTANCE p2, LPSTR p3, int p4)
{
    MessageBox(0, "Hello.", "MyProg", MB_OK);
    return 0;
}

但是MessageBox用红色下划线,并显示错误:'Function 'MessageBoxA' cannot be resolved'。SendMessage()显示了相同的错误。程序工作正常,但我不明白为什么红线在那里。: @

Eclipse无法解析WinAPI函数。您需要添加带有WinAPI头(windows.h)的文件夹到Include paths.