c++ - Eclipse报错 'Function ' MessageBoxA'无法解析'但还是编译成功?

标签 c++ eclipse winapi user-interface mingw

当使用 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 带有红色下划线,并显示错误:“无法解析函数‘MessageBoxA’”。 SendMessage() 显示相同的错误。该程序运行正常,但我无法弄清楚为什么会出现红线。 :@

最佳答案

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

关于c++ - Eclipse报错 'Function ' MessageBoxA'无法解析'但还是编译成功?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7202041/

相关文章:

java - 使用嵌入式 JRE 将 Shaded Java (jar) 构建为 Win32 可执行文件?

c++ - C/C++ 中有哪些不同的调用约定,每个约定是什么意思?

c++ - 如何在 Linux 中使用 exec 函数族执行 a.out 文件

python - django createsuperuser 不工作

c++ - 有没有办法在每个启动的新进程上从 Windows 获取事件?

c++ - 将 'this' 指针作为 LPARAM 传递

c++ - 为什么 CreateFile 无法通过网络共享打开文件?

c++ - 在 shared_ptr 中使用 deallocator & allocator

eclipse - 是否可以向 eclipse.ini 文件添加注释

eclipse - Eclipse 可以将 if-else 转换为枚举的切换吗