I have test.c in which I would like to have the statement
#include "abc.h" (the header file of libabc)
only if test.c has been compiled with libabc as:
gcc test.c -labc
If test.c is simply compiled as
gcc test.c , abc.h should not be included.
How can I do that?
One approach is to use
-Dto define a macro:If you’re running this command from Bash, then you could in principle create a shell-function wrapper around
gccto automatically add-DABCwhen-labcis specified:. . . but I don’t really recommend that.