GCC目录选项 - 系统 [英] GCC directory option -isystem

查看:116
本文介绍了GCC目录选项 - 系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过此链接: http://gcc.gnu.org/onlinedocs/gcc/Directory-Options .html


如果标准系统包含
目录,或者使用-isystem指定
的目录,也用
-I指定,-I选项将被忽略。该目录仍然会被搜索,但
作为系统目录,位于系统包含的正常
位置。




<

$ / $>
$ b

  [14:45:37 Wed Apr 27]〜/ junkPrograms / src $ gcc hello.c -isystem -I ../include/ 
../include/:file not recognized:is a directory
collect2:ld returned 1 exit status
[14:45: 〜/ junkPrograms / src $ gcc hello.c -I isystem ../include/
../include/:文件不被识别:是一个目录
collect2:ld返回1个出口状态
[14:45:57 Wed Apr 27]〜/ junkPrograms / src

这是否意味着如果连接了 -isystem ,那么dir将被赋予正常系统目录的优先权?

解决方案

文档说:


-isystem dir

在由-I指定的所有目录之后但在标准系统目录之前搜索头文件的目录。将其标记为系统目录,以便获得与应用于标准系统目录相同的特殊待遇。如果dir以=开头,那么=将被sysroot前缀替换;请参阅--sysroot和-isysroot。

所以你错了。你需要为-isystem选项本身指定一个目录,它不像你似乎在尝试的-I选项的修饰符那样工作。



我相信你的命令应该是:

  $ gcc -isystem ../include hello.c 


From this link: http://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html

If a standard system include directory, or a directory specified with -isystem, is also specified with -I, the -I option will be ignored. The directory will still be searched but as a system directory at its normal position in the system include chain.

What is the way to run this?

[14:45:37 Wed Apr 27] ~/junkPrograms/src  $gcc hello.c -isystem -I ../include/
../include/: file not recognized: Is a directory
collect2: ld returned 1 exit status
[14:45:42 Wed Apr 27] ~/junkPrograms/src  $gcc hello.c -I isystem ../include/
../include/: file not recognized: Is a directory
collect2: ld returned 1 exit status
[14:45:57 Wed Apr 27] ~/junkPrograms/src  $

and does this mean that if -isystem is attached, the dir will be given the precedence of a normal system dir?

解决方案

The documentation says:

-isystem dir

Search dir for header files, after all directories specified by -I but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories. If dir begins with =, then the = will be replaced by the sysroot prefix; see --sysroot and -isysroot.

So you're using it wrong. You need to specify a directory for the -isystem option itself, it doesn't work like a "modifier" of the -I option like you seem to be trying.

I believe your command should be:

$ gcc -isystem ../include hello.c

这篇关于GCC目录选项 - 系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆