为什么我需要在 C++ 中的所有文件中包含预编译头? [英] Why do I need to include the precompiled header in all the files in C++?

查看:30
本文介绍了为什么我需要在 C++ 中的所有文件中包含预编译头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果即使在空的 .cpp 中也不包含 stdafx,我会收到此错误

If I don't include the stdafx even in an empty .cpp, I get this error

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

为什么我需要将它包含在虚拟文件中?

Why do I need to include it even in dummy files?

推荐答案

如果您使用它们,那么您必须包含它们.但是您可以在项目属性中关闭它们.

If you use them, then you must include them. But you can turn them off in the project properties.

但是,推荐使用它们的方法是从命令行强制包含"PCH,以便文件本身不包含 PCH.这样源文件就可以与其他系统兼容.

However, the recommended way to use them is to "Force Include" the PCH from the command line, so that the file itself doesn't contain the PCH. That way the source file can be compatible with other systems.

这篇关于为什么我需要在 C++ 中的所有文件中包含预编译头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆