6

新手请教使用 VS2017 创建 Dll 项目后,如何自动生成 stdafx.h 和 targetver.h 这 2...

 2 years ago
source link: https://www.v2ex.com/t/814692
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  C++

新手请教使用 VS2017 创建 Dll 项目后,如何自动生成 stdafx.h 和 targetver.h 这 2 个文件?

  s609926202 · 17 小时 2 分钟前 · 235 次点击
这四个其他选项无论怎么组合勾选,创建项目后并没有出现 stdafx.h 和 targetver.h 这 2 个文件。

但是,看的视频教程中,同样使用 VS2017 创建项目后,这 2 个文件是会自动生成的。。

这个是什么情况,VS2017 版本不同吗、、
3 条回复    2021-11-11 16:48:51 +08:00

wangxn

wangxn   15 小时 27 分钟前 via Android

选那个预编译头的选项可以生成第一个文件

s609926202

s609926202   14 小时 40 分钟前

@wangxn 并没有,如下图他生成了一个 pch.h ,一个 framework.h

ysc3839

ysc3839   14 小时 31 分钟前   ❤️ 1

选择预编译头即可。stdafx.h 只是个预编译头的文件名,现在改成了 pch.h 而已,叫啥名不影响功能。

targetver.h 的内容一般是
```
#pragma once

// // Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.

#include <SDKDDKVer.h>
```
意思是如果你想让程序能在旧的 Windows 中跑,可以在这里定义版本号,然后头文件会把新的 API 给屏蔽掉。

对于初学者来说我个人不建议管这些,直接 include 即可,等后面开始写复杂项目了再来看这些内容。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK