如何在 Visual Studio 2017 中为 Windows XP 编译代码 [英] How to compile code for Windows XP in Visual Studio 2017

查看:129
本文介绍了如何在 Visual Studio 2017 中为 Windows XP 编译代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 Windows 10 上的 Visual Studio 2017 中为 Windows XP 编译一个基本的 hello world 程序.但它给出了一些错误,如图所示.

I was trying to compile a basic hello world program for Windows XP in Visual Studio 2017 on Windows 10. But it was giving some errors as showing in the image.

我已经尝试过关于此问题的其他 Stack Overflow 帖子中提到的步骤,并更改了平台工具Visual Studio 2017 - Windows XP (v141_xp)".

I already tried the steps mentioned in other Stack Overflow posts on this question, and changed the Platform tools "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 ==========

推荐答案

您在此处遇到的是 XP 兼容 SDK 的头文件中的问题.这个问题实际上很神秘,但幸运的是,相对容易处理:您只需要放松"编译器使用的一致性检查的严格性...

What you have encountered here are issues in the header files for the XP-Compatible SDK. The problem is actually quite arcane but, fortunately, relatively easy to deal with: you simply need to 'relax' the strictness of conformity checks the compiler uses...

为此,请在解决方案资源管理器中右键单击您的项目,然后选择属性".在调用的属性页上,选择C/C++"选项卡,然后选择语言"子选项卡.在随后显示的页面中,确保将一致性模式"选择为".这应该可以解决问题.

To do this, right-click on your project in the Solution Explorer and select "Properties." On the invoked property-page, select the "C/C++" tab, and then the "Language" sub-tab. In the page then displayed, make sure you select "Conformance Mode" to "No". That should fix the issues.

请随时要求进一步澄清和/或解释.

Feel free to ask for further clarification and/or explanation.

这篇关于如何在 Visual Studio 2017 中为 Windows XP 编译代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆