0xV*_*kas 2 c++ windows-xp visual-studio visual-c++ visual-studio-2017
我试图在 Windows 10 上的 Visual Studio 2017 中为 Windows XP 编译一个基本的 hello world 程序。但它给出了一些错误,如图所示。
我已经尝试了关于此问题的其他 Stack Overflow 帖子中提到的步骤,并更改了平台工具 "Visual Studio 2017 - Windows XP (v141_xp)" 。
#include<iostream>
using namespace std;
int main() {
cout << "Hello world\n";
}
Run Code Online (Sandbox Code Playgroud)
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 ==========
Run Code Online (Sandbox Code Playgroud)
您在此处遇到的是 XP 兼容 SDK 的头文件中的问题。这个问题实际上很神秘,但幸运的是,相对容易处理:您只需要“放松”编译器使用的一致性检查的严格性......
为此,请在解决方案资源管理器中右键单击您的项目并选择“属性”。在调用的属性页上,选择“C/C++”选项卡,然后选择“语言”子选项卡。在随后显示的页面中,确保将“一致性模式”选择为“否”。那应该可以解决问题。
随时要求进一步澄清和/或解释。
| 归档时间: |
|
| 查看次数: |
1620 次 |
| 最近记录: |