使用命令行选项包括头文件? [英] Include header files using command line option?

查看:113
本文介绍了使用命令行选项包括头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从命令行指定额外的头文件(使用GCC 4 / C ++)?



除了#include?

背景:我想在我自己的电脑上编译一个大的代码库。代码通常编译在一个集群中,有一个复杂的构建系统(SoftRelTools任何人?),它是与操作系统交织在一起的,因此几乎不可能安装在别的地方(数百个makefile和shell脚本,硬的到网络驱动器的编码路径)。然而,实际的代码是相当简单的,编译良好,但它缺少很多包括(大多是一个 include< vector> include< math.h> )。我猜,构建系统通常会照顾这一点,但我必须通过代码,手动添加包含,我宁愿避免。

解决方案

找到 -include选项。这是您想要的吗?


-include档案



#includefile出现作为
的第一行主源文件。然而,
第一目录搜索文件是
预处理器的工作目录
,而不是包含
的主目录文件的目录。如果没有找到
,那么在正常情况下在#include...
搜索链的
剩余部分中搜索



如果给出了多个-include选项,文件将包含在命令行中出现的
顺序中。



Is it possible to specify extra header files to include from the command line (using GCC 4 / C++)?

Or is there any other way files can be included except with #include?

Background: I'm trying to compile a large code base on my own PC. The code is usually compiled in a cluster, with a complicated build system (SoftRelTools anybody?), which is intertwined with the operating system, such that it is virtually impossible to install it somewhere else (literally hundreds of makefiles and shell scripts, and hard coded paths to network drives). However, the actual code is fairly straightforward, and compiles fine, BUT it is missing a lot of includes (mostly a la "include <vector>" and "include <math.h>"). I'm guessing the build system takes care of this usually, but I have to go through the code and add the includes manually, which I'd rather avoid.

解决方案

I found the -include option. Does this what you want?

-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.

这篇关于使用命令行选项包括头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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