Is there a way to ask gcc to handle #include <> like #include ""?
Is there a compiler or preprocessor flag that will make gcc handle #include <x.h>
as it would #include "x.h"
? I have a bunch of generated code that it uses #include <>
for files in the current directory and gcc reports No such file or directory for those files. I'm looking for a workaround that doesn't involve editing code.
EDIT: -I.
It doesn't. Let's say I have the following files:
Foo / foo.h:
#include <foo2.h>
Foo / foo2.h:
#define FOO 12345
xyz / xyz.c
#include <stdio.h> #include "foo/foo2.h" int main(void) { printf("FOO is %d\n", FOO); return 0; }
If xyz
compiled inside a directory with gcc -o xyz I.. xyz.c
, compilation fails:
In file included from xyz.c:2: ../foo/foo.h:1:18: error: foo2.h: No such file or directory xyz.c: In function βmainβ: xyz.c:6: error: βFOOβ undeclared (first use in this function) xyz.c:6: error: (Each undeclared identifier is reported only once xyz.c:6: error: for each function it appears in.)
Adding -I.
doesn't change anything.
But if I change foo / foo.h to:
#include "foo2.h"
Then compilation works. I know I can add -I../foo
to my command line, but I was looking for a more general way to treat #include <>
how #include ""
. Does it exist?
source share
The -I- option can help you. From the gcc man page:
-I- Split the include path. Any directories specified with -I options before -I- are searched only for headers requested with "#include "file""; they are not searched for "#include <file>". If additional directories are specified with -I options after the -I-, those directories are searched for all #include directives.
source share