I would like to specify the name of a C include file at compile time as a C flag.
e.g.
#include MY_INCLUDE_FILE
int main(int argc, const char * argv[]) {...}
Would be expaned by the pre-processor to
#include "some_incfile.h"
int main(int argc, const char * argv[]) {...}
Doing something like this
gcc -DMY_INCLUDE_FILE="some_incfile.h" main.c
I have attempted using the stringizing operator # to expand but have only gotten errors such as error: expected "FILENAME" or <FILENAME>
Is this even possible? -D define is not entirely necessary, the important part is that the include filename can be set from the gcc command line
You have to escape the ":
gcc -DMY_INCLUDE_FILE=\"some_incfile.h\" main.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With