gcc/xCode — #include that does not trigger an error (or warning) if the file does not exist?
-
29-10-2019 - |
Question
Is this possible?
Basically, what I want to do is something like this:
#includeIfItExists "header.h"
and if header.h does not exist, the compiler simply continues on its merry way.
Solution
I'm by no means an expert C guy but I don't believe that this is possible natively. I think the recommend route would be to pass in a named macro at the compiler level using -D
and if it is (or possibly is not) defined perform your include. This way the person compiling the program has to make a conscious decision to skip the include (or include it).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow