- 论坛徽章:
- 0
|
gcc test.c 报错如下
test.c:6:24: ..\test.h: No such file or directory
test.c 中有一句include "..\test.h", 在父目录下有文件test.h 当然改成include "../test.h" 编译通过。
这样的话我的程序从windows下移植过来需要修改太多的头文件定义。我记得我原来不把 \ 改成 /也是可以
编译通过的。突然不行了。不知到是否可以配置一下,gcc可以识别 \这个路径符号
test.c
#include "..\test.h"
main()
{
printf("hello world\n");
}
../test.h
#include<stdio.h> |
在不同的gcc版本下编译结果如下
gcc test.c
[root@localhost xuwei]# ./a.out
hello world
[root@localhost xuwei]# gcc -v
Reading specs from /usr/lib/gcc-lib/i586-pc-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i586-pc-linux
Thread model: posix
gcc version 3.2.3 20030502 (TurboLinux 3.2.3-10)
gcc test.c
test.c:1:22: ..\test.h: No such file or directory
[root@localhost xuwei]# gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
难道是gcc的版本决定了对这个路径符号的支持。
[ 本帖最后由 cccccc 于 2007-10-24 14:28 编辑 ] |
|