是否可以在命令行中指定额外的头文件(使用 GCC 4/C++)?
或者除了#include 之外还有其他方法可以包含文件吗?
背景:我正在尝试在我自己的 PC 上编译一个大型代码库。代码通常在集群中编译,具有复杂的构建系统(SoftRelTools 有人吗?),它与操作系统交织在一起,因此几乎不可能将其安装在其他地方(实际上是数百个 makefile 和 shell 脚本,而且很难网络驱动器的编码路径)。然而,实际的代码相当简单,并且编译得很好,但是它缺少很多包含(主要是“include <vector>
”和“include <math.h>
”)。我猜构建系统通常会处理这个问题,但我必须通过代码并手动添加包含,我宁愿避免这样做。
最佳答案
我 found -include 选项。这是你想要的吗?
-include file
Process file as if "#include "file"" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the "#include "..."" search chain as normal.
If multiple -include options are given, the files are included in the order they appear on the command line.
关于c++ - 使用命令行选项包含头文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3387453/