关于我的编译器中缺少 stdafx.h(Windows 上的 mingw32)
我有一个简单的问题。我注意到我的编译器中没有 stdafx.h(Windows 上的 mingw32)
我应该有它吗?或者也许有办法绕过它?
感谢您的阅读
编辑:好的,这是我当前的构建日志,一旦我取出 stdafx.h
I just have a quick question. I've noticed that I don't have stdafx.h in my compiler(mingw32 on windows)
Am I supposed to have it? Or maybe is there a way to get around it?
Thanks for reading
EDIT: ok here is my current build log once I took out ALL of the includes of stdafx.h
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
阅读这篇维基百科文章。我链接的段落及其下面的段落(mingw32 使用 GCC)。
http://en.wikipedia.org/wiki/Precompiled_header#stdafx.h
由于
stdafx.h
包含最常见的标头,我将删除#include stdafx.h
的每个实例并尝试编译。如果您收到缺少某个函数的编译错误,请添加适当的标头。冲洗并重复。Read this wikipedia article. The paragraph I linked and the paragraph below it (mingw32 uses GCC).
http://en.wikipedia.org/wiki/Precompiled_header#stdafx.h
Since
stdafx.h
contains the most common headers I would remove every instance of#include stdafx.h
and try to compile. If you get compile errors that a certain function is missing, add the appropriate header. Rinse and repeat.不会。
Stdafx.h
是使用 MSVC++ 创建的。它通常包含最常见的头文件。Stdafx.h
包含在每个 .cpp 文件的开头。它是预编译标头(如果您我在 MSVC++ 创建的设置中选择了这个。No.
Stdafx.h
is created with MSVC++. It usually contains most common headers files. AndStdafx.h
is included in every .cpp file in the beginning. It's precompiled header (if you've chosen so in the settings) created by MSVC++.致所有人:
如果您从 Visual C++ 创建了“Windows 控制台应用程序”,则在 Visual C++ 中使用预编译头文件 stdafx.h 总是会产生一个或另一个问题。
解决方案是,只需创建“空项目”,而不是预编译的 Windows 控制台应用程序。创建空项目后,创建源文件。编写业务逻辑并添加所有所需的资源和头文件。将外部依赖项文件保存在源代码所在的同一目录中:例如,C:\Users\John\Documents\Visual Studio 2010\Projects\xyz.cpp\xyz.cpp。
最后将源文件添加到全局范围,即将其添加到已经创建的“空项目”中。可以通过在 Visual Studio 提示符下单击“文件”并选择将源文件添加到项目的选项来完成。
感谢和问候:
鲁夫·汗
To all:
Using the pre compiled header file stdafx.h in the visual C++ always creates one or the other problem n case u have created a "Windows Console App" from Visual C++.
The Solution to it is that, just create "Empty Project", rather than the pre-compiled windows console application. After creating the Empty project, create the source File. Write the business logic and add all the required resource and header files. Keep the external dependency files in the same directory in which your source code is: e.g., C:\Users\John\Documents\Visual Studio 2010\Projects\xyz.cpp\xyz.cpp.
Finally add the source file to the global scope, that is add it to the "Empty Project" created already. It can be done by Clicking "File" on Visual Studio prompt and select the option of adding the source file to the project.
Thanks and Regards:
Rouf Khan