I want the preprocessor to read in the includes of local headers, but ignore the includes of system headers. To put it another way, how do I get the preprocessor to skip ov
You can protect the system includes with a temporarily included comment, keep comments in the preprocessor output (-CC
) and then remove the protectors again.
Something like:
sed -i 's%#include <%//PROTECTED #include <%g' $(find . -name '*.[hc]pp')
g++ -E -P -CC main.cpp -o new_main.cpp
sed -i 's%//PROTECTED %%g' new_main.cpp
Since you are modifying the source files, it might be a good idea to create a copy first and work on those copies instead. Plus some other details, but the above is the general idea you need.