GDI+ library causes quot;error C2760: syntax error: unexpected token #39;identifier#39;, expected #39;type specifier#39;quot; in VS2017 when compiled for XP(GDI+ 库导致“错误 C2760:语法错误:意外标记‘标识符’,预期‘类型说明符’在 VS2017 中为 XP 编译时) - IT屋-程序员软件开发技术
问题描述
我正在尝试将以下 GDI+ 定义包含在我在 Visual Studio 2017 下编译的 Win32 C++ 项目中:
I'm trying to include the following definitions for GDI+ into my Win32 C++ project that is compiled under Visual Studio 2017:
#include <objidl.h>
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")
我需要编译这个项目以支持 Windows XP.所以在我选择的项目属性中:Platform Toolset
as Visual Studio 2017 - Windows XP (v141_xp)
:
I need to compile this project to support Windows XP. So in the project properies I selected: Platform Toolset
as Visual Studio 2017 - Windows XP (v141_xp)
:
但是当我编译它时,GDI+ 库给了我这个:
But when I compile it the GDI+ library gives me this:
1>c:program files (x86)microsoft sdkswindowsv7.1aincludeobjbase.h(239): error C2760: syntax error: unexpected token 'identifier', expected 'type specifier'
1>c:program files (x86)microsoft sdkswindowsv7.1aincludegdiplusheaders.h(891): error C4596: 'EmfToWmfBits': illegal qualified name in member declaration
1>c:program files (x86)microsoft sdkswindowsv7.1aincludegdiplusstringformat.h(220): error C4596: 'GetTrimming': illegal qualified name in member declaration
知道如何解决这个问题吗?
Any idea how to fix this?
推荐答案
在COM相关标头的第一个(!)#include
之前添加此行以修复objbase.h(239):错误 C2760:语法错误:意外标记标识符",预期的类型说明符"
:
Add this line before the very first(!) #include
of COM-related header to fix 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还没有在那个地方宣布.
This fix works, because the line in objbase.h(239)
mentioned in the error contains static_cast<IUnknown*>(*pp);
despite that IUnknown still haven't been declared in that place.
这篇关于GDI+ 库导致“错误 C2760:语法错误:意外标记‘标识符’,预期‘类型说明符’"在 VS2017 中为 XP 编译时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:GDI+ 库导致“错误 C2760:语法错误:意外标记‘标识符’,预期‘类型说明符’"在 VS2017 中为 XP 编译时
- 从python回调到c++的选项 2022-11-16
- Stroustrup 的 Simple_window.h 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- C++ 协变模板 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01