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 编译时


基础教程推荐
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 在 C++ 中计算滚动/移动平均值 2021-01-01