c++ - GDI+ 库导致 "error C2760: syntax error: unexpected token ' 标识符',在 VS2017 中为 XP 编译时预期为 'type specifier'"

标签 c++ visual-studio-2017 gdi+

我正在尝试将 GDI+ 的以下定义包含到我在 Visual Studio 2017 下编译的 Win32 C++ 项目中:

#include <objidl.h>
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")

我需要编译这个项目来支持 Windows XP。所以在我选择的项目属性中:Platform ToolsetVisual Studio 2017 - Windows XP (v141_xp) :

enter image description here

但是当我编译它时,GDI+ 库给了我这个:
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\objbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\gdiplusheaders.h(891): error C4596: 'EmfToWmfBits': illegal qualified name in member declaration
1>c:\program files (x86)\microsoft sdks\windows\v7.1a\include\gdiplusstringformat.h(220): error C4596: 'GetTrimming': illegal qualified name in member declaration

知道如何解决这个问题吗?

最佳答案

在第一个 (!) #include 之前添加这一行修复 COM 相关头文件 objbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier' :

typedef struct IUnknown IUnknown;

此修复程序有效,因为 objbase.h(239) 中的行错误中提到的包含static_cast<IUnknown*>(*pp);尽管 IUnknown 仍然没有在那个地方声明。

关于c++ - GDI+ 库导致 "error C2760: syntax error: unexpected token ' 标识符',在 VS2017 中为 XP 编译时预期为 'type specifier'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57014731/

相关文章:

c++ - 当我不再需要它们时如何放弃提升的特权

C++查找子字符串中字符串的最后一次出现

c# - 将 Azure Function 从门户导入 Visual Studio

c# - 基于两点绘制工字梁

c# - 在 WinForms 应用程序中准确测量、渲染、 HitTest 和打印文本

c++ - Const 对 Copy Constructor 重要吗?

c++ - HttpSendRequest 失败并出现错误 12015

c# - Visual Studio : [DebuggerDisplay], 在指定格式时显示 "not a valid format specifier"

c++ - 防止控制台窗口在 Visual Studio 2017 cmake 项目中关闭

c# - 为什么 EnumerateMetafile 只能在启用 Aero 的情况下使用