简体   繁体   English

用于针对XP的Visual Studio 2013的Visual C ++编译器标志

[英]Visual C++ Compiler Flag for Visual Studio 2013 for Targeting XP

I want to create a C++ program with Visual Studio 2013 targeted for the XP environment, I am aware of the UI option in Project Properties -> Configuration tab to set the the Platform Tool set top Windows v120_xp, I want to acheive that using the command line options. 我想用针对XP环境的Visual Studio 2013创建一个C ++程序,我知道Project Properties - > Configuration选项卡中的UI选项来设置Platform Tool set top Windows v120_xp,我想用命令实现它行选项。 How to do that. 怎么做。

For visual studio 2012 I am aware of the option 对于visual studio 2012,我知道这个选项

set CL=/D_USING_V110_SDK71_;%CL% 设置CL = / D_USING_V110_SDK71 _;%CL%

I am looking for similar option is Visual Studio 2013. Can you please help? 我正在寻找类似的选项是Visual Studio 2013.你能帮忙吗?

The _USING_V110_SDK71_ macro has nothing to do with building your program to be compatible with XP, it is merely a side-effect. _USING_V110_SDK71_宏与构建程序与XP兼容无关,它只是一个副作用。 The essential option is a linker option, /SUBSYSTEM . 基本选项是链接器选项/ SUBSYSTEM Note how this option lets you specify the major and minor sub-system version number. 请注意此选项如何指定主要和次要子系统版本号。 Your program can only run on XP if you set this option to 5,1. 如果将此选项设置为5,1,则程序只能在XP上运行。 Starting with VS2012, the default setting is 6,0 which is the version number of the current generation of Windows. 从VS2012开始,默认设置为6,0,即当前Windows版本的版本号。 Vista or higher is required to run such a program. 运行此类程序需要Vista或更高版本。

This is actually rather a big deal, downgrading the version number turns on some app-compat shims in Windows that were designed to deal with a program that announces that it doesn't know anything about a modern Windows version. 这实际上是一个大问题,降级版本号打开Windows中的一些app-compat垫片,旨在处理一个程序宣布它对现代Windows版本一无所知。 Particularly the way Aero lies about the window metrics, designed to allow an ancient program to still run with fat window borders. 特别是Aero关于窗口指标的方式,旨在允许古代程序仍然使用胖窗口边界运行。

The CRT is also affected, fairly obscure details related to threading and localization. CRT也受到影响,与线程和本地化相关的相当模糊的细节。 Testing is required of course. 当然需要进行测试。 Keep the cost of supporting such an ancient operating system in mind. 保持支持这样一个古老的操作系统的成本。

Last but not least, you also need to use an appropriate SDK version. 最后但同样重要的是,您还需要使用适当的SDK版本。 The last one that's still compatible with XP is v7.1. 最后一个仍与XP兼容的是v7.1。 If you build from the command line then you'll get 8.1, you need to fix that by setting the %WindowsSdkDir% environment variable first. 如果从命令行构建然后获得8.1,则需要先通过设置%WindowsSdkDir%环境变量来解决此问题。 And you need to set the target Windows version in your headers that #include Windows.h, hopefully a precompiled header. 并且您需要在#include Windows.h的标头中设置目标Windows版本,希望是预编译的标头。 Define _WIN32_WINNT to 0x501 to match XP and avoid accidentally using winapi functions that are not available on XP. 将_WIN32_WINNT定义为0x501以匹配XP,并避免意外使用XP上没有的winapi函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM