为什么stddef.h不在/ usr / include中? [英] Why is stddef.h not in /usr/include?
问题描述
我编译了gnu标准库,并将其安装在 $ GLIBC_INST
中。
现在,我尝试编译非常简单的程序(仅使用一个#include: #include
):
gcc --nostdinc -I $ GLIBC_INST / include foo.c
编译(预处理器?)告诉我,它没有找到 stddef.h
。
事实上, $ GLIBC_INST / include
中没有一个( / usr / include
)。不过,我在 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include 中找到
stddef.h
code>。
为什么该文件不在 / usr / include
下?我认为它属于标准C库,应该安装在 $ GLIBC_INST / include
中。
我怎么能编译我的 foo.c
与新安装的标准库时,它似乎不带有 stddef.h
?
编辑:澄清
我觉得这个问题的标题是不是最佳的。正如一些答案指出的那样,不需要 stddef.h
位于 / usr / include
(或 $ GLIBC_INST / include
,就此而言)。我明白这一点。
但我想知道如何在我想使用 $ GLIBC_INST
时继续操作。我似乎很明白(虽然我可能在这里是错误的),我需要调用与 - nostdinc
gcc为了不使用系统安装的头文件。
这意味着我使用 -I $ GLIB_INST / include
。我清楚这一点。
然而,我还不清楚的是:当我还添加 -I / usr / lib / gcc / x86 .... / include
,我怎么能确定我确实拥有新编译的glibc的最新头文件?
这是因为 glibc
,而 / usr / lib / gcc
中的文件是特定于该特定编译器的文件。通常每个编译器都有自己的 stddef.h
不同的实现,但它们将使用相同的 stdio.h
当链接到安装的C库时。
I have compiled the gnu standard library and installed it in $GLIBC_INST
.
Now, I try to compile a very simple programm (using only one #include : #include <stdio.h>
):
gcc --nostdinc -I$GLIBC_INST/include foo.c
The compilation (preprocessor?) tells me, that it doesn't find stddef.h
.
And indeed, there is none in $GLIBC_INST/include
(nor is there one in /usr/include
). However, I found a stddef.h
in /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include
.
Why is that file not under /usr/include
? I thought it belonged to the standard c library and should be installed in $GLIBC_INST/include
.
How can I compile my foo.c
with the newly installed standard library when it doesn't seem to come with a stddef.h
?
Edit: Clarification
I feel that the title of this question is not optimal. As has been pointed out by some answers, there is not a requirement for stddef.h
to be in /usr/include
(or $GLIBC_INST/include
, for that matter). I do understand that.
But I am wondering how I can proceed when I want to use $GLIBC_INST
. It seems obvious to me (although I might be wrong here) that I need to invoke gcc with --nostdinc
in order to not use the system installed header files.
This entails that I use -I$GLIB_INST/include
. This is clear to me.
Yet, what remains unclear to me is: when I also add -I/usr/lib/gcc/x86..../include
, how can I be sure that I do have in fact the newest header files for the freshly compiled glibc?
That's because files under /usr/include
are common headers that provided by the C library, for example, glibc
, while the files at /usr/lib/gcc
are specific for that particular compiler. It is common that each compiler has their own different implementation of stddef.h
, but they will use the same stdio.h
when links to the installed C library.
这篇关于为什么stddef.h不在/ usr / include中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!