Include header files using command line?

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

Or are there any other files that can be included besides #include?

Reference Information. I am trying to compile a large code base on my PC. The code is usually compiled in a cluster with a complex build system (SoftRelTools - anyone?), Which is intertwined with the operating system, so it is almost impossible to install it somewhere else (literally hundreds of make files and shell scripts and encoded paths to network drives ) However, the actual code is pretty simple and compiles fine, but it lacks a lot of inclusions (mostly a la include <vector> and include <math.h> ). I assume the build system will take care of this normally, but I need to go through the code and add it manually, which I would rather avoid.

+53
c ++ gcc include
Aug 02 2018-10-02T00:
source share
3 answers

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

-include file

Treat the file as if the #include file appeared as the first line of the primary source file. However, searching for the first folder in the file preprocessor working directory instead of the directory containing the main source file. If not found there, it is looked for in the remainder of "#include". .. "" search chain as usual.

If options with multiple inclusions are specified, the files are included so that they appear on the command line.

+61
Aug 02 2018-10-12T00:
source share

From the gcc manual:

-include file

Process the file as if " #include "file" " appeared as the first line of the main source file. However, the first directory that the file is looking for is the preprocessor working directory instead of the directory containing the main source file. If not found, he will search the rest of the search chain " #include "..." " as usual.

If options with multiple inclusions are specified, the files are included in the order that they appear on the command line.

+22
Aug 02 2018-10-12T00:
source share

According to the gcc documentation, the "-include file" command line switch will complete the task.

+7
Aug 2 2018-10-12T00:
source share



All Articles