V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
s609926202
V2EX  ›  C++

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

  •  
  •   s609926202 ·
    shangdev · 2021-11-11 14:18:24 +08:00 · 1208 次点击
    这是一个创建于 868 天前的主题,其中的信息可能已经有所发展或是发生改变。


    这四个其他选项无论怎么组合勾选,创建项目后并没有出现 stdafx.h 和 targetver.h 这 2 个文件。

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

    这个是什么情况,VS2017 版本不同吗、、
    3 条回复    2021-11-11 16:48:51 +08:00
    wangxn
        1
    wangxn  
       2021-11-11 15:53:34 +08:00 via Android
    选那个预编译头的选项可以生成第一个文件
    s609926202
        2
    s609926202  
    OP
       2021-11-11 16:40:09 +08:00
    @wangxn 并没有,如下图他生成了一个 pch.h ,一个 framework.h


    ysc3839
        3
    ysc3839  
       2021-11-11 16:48:51 +08:00   ❤️ 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 即可,等后面开始写复杂项目了再来看这些内容。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3231 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:16 · PVG 20:16 · LAX 05:16 · JFK 08:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.