• <bdo id='8emvR'></bdo><ul id='8emvR'></ul>
    1. <i id='8emvR'><tr id='8emvR'><dt id='8emvR'><q id='8emvR'><span id='8emvR'><b id='8emvR'><form id='8emvR'><ins id='8emvR'></ins><ul id='8emvR'></ul><sub id='8emvR'></sub></form><legend id='8emvR'></legend><bdo id='8emvR'><pre id='8emvR'><center id='8emvR'></center></pre></bdo></b><th id='8emvR'></th></span></q></dt></tr></i><div id='8emvR'><tfoot id='8emvR'></tfoot><dl id='8emvR'><fieldset id='8emvR'></fieldset></dl></div>
    2. <legend id='8emvR'><style id='8emvR'><dir id='8emvR'><q id='8emvR'></q></dir></style></legend>
      <tfoot id='8emvR'></tfoot>

      <small id='8emvR'></small><noframes id='8emvR'>

      我可以使用 #include "pch.h" 吗?而不是 #include "stdafx

      Can I use #include quot;pch.hquot; instead of #include quot;stdafx.hquot; as my precompile header in Visual Studio C++?(我可以使用 #include pch.h 吗?而不是 #include stdafx.h;作为我在 Visual Studio C++ 中的预编译头文件?) - IT屋-程序员软件开
      <legend id='FWrUZ'><style id='FWrUZ'><dir id='FWrUZ'><q id='FWrUZ'></q></dir></style></legend>
          <tbody id='FWrUZ'></tbody>
        • <bdo id='FWrUZ'></bdo><ul id='FWrUZ'></ul>

            <i id='FWrUZ'><tr id='FWrUZ'><dt id='FWrUZ'><q id='FWrUZ'><span id='FWrUZ'><b id='FWrUZ'><form id='FWrUZ'><ins id='FWrUZ'></ins><ul id='FWrUZ'></ul><sub id='FWrUZ'></sub></form><legend id='FWrUZ'></legend><bdo id='FWrUZ'><pre id='FWrUZ'><center id='FWrUZ'></center></pre></bdo></b><th id='FWrUZ'></th></span></q></dt></tr></i><div id='FWrUZ'><tfoot id='FWrUZ'></tfoot><dl id='FWrUZ'><fieldset id='FWrUZ'></fieldset></dl></div>
            <tfoot id='FWrUZ'></tfoot>
            • <small id='FWrUZ'></small><noframes id='FWrUZ'>

              1. 本文介绍了我可以使用 #include "pch.h" 吗?而不是 #include "stdafx.h";作为我在 Visual Studio C++ 中的预编译头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是我第一次使用 C++ 并正确地开始编码.我正在关注 learncpp.com 上的 C++ 教程,并且我正在使用 Visual Studio 2017 ...

                This is my first time working with C++ and properly getting into coding. I'm following the C++ tutorials on learncpp.com and I'm using Visual Studio 2017...

                在教程中,他们从一些简单的Hello, world!"开始.在代码的顶部,他们将 #include "stdafx.h"#include 放在一起.当我自己复制此代码并尝试构建它时,出现错误:

                In the tutorial they start off with some simple "Hello, world!" code and at top of the code they put #include "stdafx.h" along with #include <iostream>. When I replicate this code myself and try to build it, I get the error:

                C1010:查找预编译头时意外的文件结尾.您是否忘记将 #include "pch.h" 添加到您的源代码中?

                C1010: unexpected end of file while looking for precompiled header. Did you forget to add #include "pch.h" to your source?

                查看我的解决方案资源管理器时,我注意到在他们的教程中的头文件和源文件选项卡中,他们有名为stdafx.h"和stdafx.cpp"的文件,但对我来说这些文件称为pch.h"和pch.cpp".

                When looking at my solution explorer I noticed that in their tutorial in the header and source files tab they have files called "stdafx.h" and "stdafx.cpp", but for me those files are called "pch.h" and "pch.cpp".

                然后我尝试将 #include "stdafx.h" 重命名为 #include "pch.h" 并且代码被完美地构建和执行.那么我应该在其余代码中坚持使用 #include "pch.h" 还是这是某种问题?

                So I then tried renaming the #include "stdafx.h" to #include "pch.h" and the code was built and executed perfectly. So should I just stick with #include "pch.h" for the rest of my code or is this some kind of issue?

                谢谢!

                推荐答案

                几年来,默认的预编译头文件名称是 stdafx.h.最近,在 VS 2017 中,他们将项目向导创建的默认名称更改为 pch.h.我不知道为什么,但他们做到了.

                The default precompiled headers name was stdafx.h for several years now. Lately, with VS 2017, they changed the default name the project wizard creates to pch.h. I don't know why but they did it.

                可以在Configuration Properties -> C/C++ -> Precompiled Headers下的Project Properties中调整预编译头文件的名称.您还可以在那里启用或禁用它们.您甚至可以在每个文件的基础上定义它.您甚至可以在一个项目中配置多个不同的预编译头文件.

                You can adjust the name of the precompiled header file in the Project Properties under Configuration Properties -> C/C++ -> Precompiled Headers. You can also enable or disable the use of them there. You can even define this on a per file basis. You can even configure multiple different Precompiled Header files in one project.

                所以对于你的具体问题:在你的教程中用 pch.h 替换 stdafx.h 不会有任何问题.该教程可能只是较旧,尚未更新.

                So for you concrete question: There won't be any kind of issue replacing stdafx.h with pch.h in your tutorial. The tutorial is probably just older and hasn't been updated yet.

                这篇关于我可以使用 #include "pch.h" 吗?而不是 #include "stdafx.h";作为我在 Visual Studio C++ 中的预编译头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Is Type(::x); valid?(是类型(::x);有效的?)
                Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)
                • <small id='dbpSW'></small><noframes id='dbpSW'>

                • <i id='dbpSW'><tr id='dbpSW'><dt id='dbpSW'><q id='dbpSW'><span id='dbpSW'><b id='dbpSW'><form id='dbpSW'><ins id='dbpSW'></ins><ul id='dbpSW'></ul><sub id='dbpSW'></sub></form><legend id='dbpSW'></legend><bdo id='dbpSW'><pre id='dbpSW'><center id='dbpSW'></center></pre></bdo></b><th id='dbpSW'></th></span></q></dt></tr></i><div id='dbpSW'><tfoot id='dbpSW'></tfoot><dl id='dbpSW'><fieldset id='dbpSW'></fieldset></dl></div>
                    <tbody id='dbpSW'></tbody>
                    <bdo id='dbpSW'></bdo><ul id='dbpSW'></ul>
                  • <legend id='dbpSW'><style id='dbpSW'><dir id='dbpSW'><q id='dbpSW'></q></dir></style></legend>

                        • <tfoot id='dbpSW'></tfoot>