Is there a way to include a header in each compilation unit without changing each source file?

Given the following:

  • large project with thousands of C ++ source files
  • no common header file (not a single header that is included in each source file)
  • the specified project is compiled with g ++ and managed by make

Is it possible to include a definition (for example, a macro) in each compilation unit without changing each source file to include a new header file?

+3
source share
2 answers

From the gcc man:

-include file

, #include "    .    -    . ,    " #include "..."    .    include,   , .

+14

"-D" gcc.

: gcc -ansi -Wall -Dblah='mymacrohere()' blah.cpp

: GCC, ,

+9

Source: https://habr.com/ru/post/1703604/


All Articles