【问题标题】:How to change the project target in visual studio如何在 Visual Studio 中更改项目目标
【发布时间】:2021-01-29 05:24:36
【问题描述】:

我正在 Visual Studio 2017 上构建一个 C++ 项目,编译器会提供此信息。

 Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target)

我在系统上以及项目设置-> 配置属性-> 常规中安装了 windows 10。

Target 平台已定义为 windows 10。

如何将目标设置为 Windows 10。

这是编译器给出的信息。

Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
1>- add -D_WIN32_WINNT=0x0601 to the compiler command line; or
1>- add _WIN32_WINNT=0x0601 to your project's Preprocessor Definitions.
1>Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target).

【问题讨论】:

    标签: visual-studio visual-c++


    【解决方案1】:

    通过将_WIN32_WINNT 定义为适当的值来设置最低操作系统版本要求,如Update WINVER and _WIN32_WINNT 中所述, Using the Windows Headers 有更多详细信息。

    • 添加预处理器定义以应用于整个构建,例如针对 Windows 10 在 VS IDE 中的 Configuration Properties / C/C++ / Preprocessor 下添加 _WIN32_WINNT=0x0A00,或在 cl 命令行上添加 /D_WIN32_WINNT=0x0A00 (或在 makefile 中)。

    • #define 共享标头中的宏。

      #include <winsdkver.h>
      
      // uncomment to target Win 10 19H1 or later
      // #define NTDDI_VERSION NTDDI_WIN10_19H1
      
      // target Win 10
      #define _WIN32_WINNT _WIN32_WINNT_WIN10
      
      #include <sdkddkver.h>
      #include <windows.h>
      

    要对目标版本进行更细粒度的控制,请在 _WIN32_WINNT 旁边定义 NTDDI_VERSION,例如 Windows 10 19H1 或更高版本的 /DNTDDI_VERSION=0x0A000007 /D_WIN32_WINNT=0x0A00

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 2013-09-30
      • 1970-01-01
      • 1970-01-01
      • 2012-08-02
      • 2010-12-05
      • 2014-01-25
      • 1970-01-01
      • 2023-03-15
      相关资源
      最近更新 更多