免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2804 | 回复: 2
打印 上一主题 下一主题

linux下gcc 能够识别路径符号 \ 吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-24 14:04 |只看该作者 |倒序浏览
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 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-10-24 14:07 |只看该作者
linux下用/做路径分割符不是\

论坛徽章:
0
3 [报告]
发表于 2007-10-24 16:13 |只看该作者
\/有点不一样
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP