I have a file included, not within the project root – let’s say “root/libs/lib.h“. Now, this file itself is including several (lots of actually) files. And, they are all in another subdirectory, lets say “root/libs/includes“. Now, I have to write this in the lib.h:
#include "includes/file1.c"
#include "includes/file2.c"
/*and so on*/
#include "includes/file20.c"
Now, wouldn’t it be easier, and more flexible, if i could change actual include path?
#set_include_path "includes";
#include "file1.c"
/* ... */
#include "file20.c"
#set_include_path ".."; //returning to original folder
I believe this is compiler dependent feature, so for replies, mention the compiler too. I’m using G++ myself.
You want to use the
-Icommand line argument:For more information, please see the reference.