rateltalk
V2EX  ›  C++

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

  •  
  •   rateltalk ·
    shangdev · Nov 11, 2021 · 2035 views
    This topic created in 1649 days ago, the information mentioned may be changed or developed.


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

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

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


    ysc3839
        3
    ysc3839  
       Nov 11, 2021   ❤️ 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   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1025 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:27 · PVG 06:27 · LAX 15:27 · JFK 18:27
    ♥ Do have faith in what you're doing.