c++ - 使用命令行选项包含头文件?

标签 c++ gcc include

是否可以在命令行中指定额外的头文件(使用 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/

相关文章:

c++ - 2 位输入的表达式树

c++ - 最快代码的 GCC 建议和选项

c++ - 升级 gcc 编译器/其他修复以实现向后兼容

c++ - 为什么这个动态库加载代码用gcc可以用?

java - 我可以将一个文件中的代码包含到下一个文件中吗,类似于 html 中的 Includes

php - 快速 PHP 变量指南

C++ "error: multiple types in one declaration"和 "error: expected initializer before ' KeyType'”

c++ - Hu 矩和 SVM 不起作用

c++ - 如何为模板类型创建别名?

python - 在Python中,如何在不更改命名空间的情况下以宏样式将一个文件包含(而不是导入)另一个文件中?