有没有编译器或预处理器标志,可以强制gcc将
编辑:
如果我在
#include <x.h>
视为#include "x.h"
? 我有一堆生成的代码使用#include <>
引用当前目录中的文件,但是gcc报告这些文件不存在。 我正在寻找一种解决方法,不涉及编辑代码。编辑:
-I。
无法解决此问题。 假设我有以下文件:
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;
}
如果我在
xyz
目录内使用gcc -o xyz I.. xyz.c
编译,编译会失败。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.)
添加-I。
不会改变任何东西。
但是,如果我将foo/foo.h更改为:
#include "foo2.h"
然后编译就可以了。我知道我可以在命令行中添加-I../foo
,但我正在寻找一种更通用的方法来将#include <>
视为#include ""
。是否存在这样的方法?