C++ SDKDDKVer.h 有什么用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10539391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 14:11:45  来源:igfitidea点击:

what is SDKDDKVer.h for?

c++windowsvisual-c++

提问by jokoon

All project created with MSVC have stdafx, which is precompiled headers, which I know what they are but what about targetver.h ? It includes SDKDDKVer.h, and I can't find what is that header about.

所有用 MSVC 创建的项目都有 stdafx,它是预编译的头文件,我知道它们是什么,但是 targetver.h 呢?它包括 SDKDDKVer.h,我找不到那个标题是什么。

What is this for ?

这个是来做什么的 ?

回答by Andy

targetver.hand SDKDDKVer.hare used to control what functions, constants, etc. are included into your code from the Windows headers, based on the OS that you want your program to support. I believe that targetver.hsets defaults to using the latest version of Windows unless the defines are specified elsewhere.

targetver.hSDKDDKVer.h用于根据您希望程序支持的操作系统来控制从 Windows 头文件中将哪些函数、常量等包含到您的代码中。我相信targetver.h除非在其他地方指定了定义,否则设置默认使用最新版本的 Windows。

SDKDDKVer.his the header file that actually defines the #definesthat represent each version of Windows, IE, etc.

SDKDDKVer.h是实际定义#defines代表每个版本的 Windows、IE 等的头文件。

回答by Pressacco

Line 193 of the SDKDDKVer.h(in SDK 8.1) states:

SDKDDKVer.h(在 SDK 8.1 中)的第 193 行指出:

"if versions aren't already defined, default to most current"

“如果尚未定义版本,则默认为最新版本”

This comment is specifically referring to the _WIN32_WINNTand NTDDI_VERSIONmacros.

此注释特指_WIN32_WINNTNTDDI_VERSION宏。

So..

所以..

  1. SDKDDKVer.happlies default values unless the macros have already been defined
  2. the following code can be used to explicitly define the macros
    • #define _WIN32_WINNT 0x0601
    • #define NTDDI_VERSION 0x06010000
  3. Interestingly enough, the SDKDDKVer.hheader file has 'constant' values defined for all of the SDK versions. For example:
    • #define _WIN32_WINNT_WINXP 0x0501
    • #define _WIN32_WINNT_WIN7 0x0601
    • #define _WIN32_WINNT_WIN8 0x0602
  4. One convention is to define _WIN32_WINNTand NTDDI_VERSIONin a header file called TargetVer.h, which you would reference in your pre-compiled header StdAfx.h.
  1. SDKDDKVer.h除非宏已经定义,否则应用默认值
  2. 以下代码可用于显式定义宏
    • #define _WIN32_WINNT 0x0601
    • #define NTDDI_VERSION 0x06010000
  3. 有趣的是,SDKDDKVer.h头文件为所有 SDK 版本定义了“常量”值。例如:
    • #define _WIN32_WINNT_WINXP 0x0501
    • #define _WIN32_WINNT_WIN7 0x0601
    • #define _WIN32_WINNT_WIN8 0x0602
  4. 一种约定是在名为 的头文件中定义_WIN32_WINNT和,您将在预编译NTDDI_VERSION的头文件中TargetVer.h引用该文件StdAfx.h

ADDTIONAL READING

附加阅读