Search code examples
cgccincludebuild-processc-preprocessor

Make the C preprocessor ignore certain #include directives


I use a parser generator here, that unfortunately insists on putting a

#include <some/file.h>

at the top of every generated source file. The header has since long been renamed. While it is no problem forcing the compiler (gcc) to use the new header with -include new/header.h, removing the above directive from every generated file complicates the build-process.

Is there a way to tell gcc to simply ignore some/file.h?


Solution

  • No. You can post-process your generated file - I say: NO!!!

    Or you can just add '.' to your system include directories (or whatever your local include path is - make sure it's also a <> system include path).

    Then make a 'some' directory and stick your own permanent 'file.h' in there that has 1 line for #include and get rid of your -include.

    I'm guess there's some reason that might not work - cause it seems like the more straight forward and understandable thing to do before using -include. Especially since you can comment the pass-through file to explain what's going on.