如何在Visual Studio 2017中编译Windows XP的代码

问题描述 投票:0回答:1

我正在尝试在Windows 10上的Visual Studio 2017中为Windows xp编译一个基本的hello world程序,但是在图像中显示时却出现了一些错误。

我已经尝试过此问题的其他stackoverflow帖子中提到的步骤,并更改了平台工具“ Visual Studio 2017-Windows XP(v141_xp)”。

#include<iostream>
using namespace std;
int main() {
    cout << "Hello world\n";
}
1>------ Build started: Project: WindowsProject1, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\v141_xp\Toolset.targets(39,5): warning MSB8051: Support for targeting Windows XP is deprecated and will not be present in future releases of Visual Studio. Please see https://go.microsoft.com/fwlink/?linkid=2023588 for more information.
1>stdafx.cpp
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
1>Done building project "WindowsProject1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

c++ visual-studio visual-c++ windows-xp
1个回答
0
投票

您在这里遇到的是XP兼容SDK的头文件中的问题。问题实际上是相当神秘的,但是幸运的是,相对而言,它很容易处理:您只需要“放松”编译器使用的一致性检查的严格性即可。...

为此,请在Solution Explorer中右键单击您的项目,然后选择“属性”。在调用的属性页面上,选择“ C / C ++”选项卡,然后选择“语言”子选项卡。在随后显示的页面中,确保将“一致性模式”选择为“ ”。那应该解决问题。

随时要求进一步的澄清和/或解释。

© www.soinside.com 2019 - 2024. All rights reserved.