我如何才能找到在Linux下C编程语言的头文件? [英] How can I find the header files of the C programming language in Linux?
问题描述
当我写在Linux的C程序,然后使用gcc编译它们,我总是好奇这些头文件在哪里。例如,在 stdio.h中
是。更一般地,哪里是 stdbool.h
?
When I write C programs in Linux, and then compile them using gcc, I am always curious about where those header files are. For example, where stdio.h
is. More generally, where is stdbool.h
?
不仅是我想知道的是它在哪里,又是如何得到那些地方,例如,使用shell命令或使用C编程语言。
What I want to know is not only where it is, but also how to get those places, for example, using shell command or using the C programming language.
推荐答案
GCC -H ...
将打印的每一个的完整路径包括文件作为一个副作用定期编制。使用 -fsyntax只
除了得到它没有创建任何输出(它仍然会告诉你,如果你的程序有错误)。示例(Linux上,GCC-4.7):
gcc -H ...
will print the full path of every include file as a side-effect of regular compilation. Use -fsyntax-only
in addition to get it not to create any output (it will still tell you if your program has errors). Example (Linux, gcc-4.7):
$ cat > test.c
#include <stdbool.h>
#include <stdio.h>
^D
$ gcc -H -fsyntax-only test.c
. /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stdbool.h
. /usr/include/stdio.h
.. /usr/include/features.h
... /usr/include/x86_64-linux-gnu/bits/predefs.h
... /usr/include/x86_64-linux-gnu/sys/cdefs.h
.... /usr/include/x86_64-linux-gnu/bits/wordsize.h
... /usr/include/x86_64-linux-gnu/gnu/stubs.h
.... /usr/include/x86_64-linux-gnu/bits/wordsize.h
.... /usr/include/x86_64-linux-gnu/gnu/stubs-64.h
.. /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h
.. /usr/include/x86_64-linux-gnu/bits/types.h
... /usr/include/x86_64-linux-gnu/bits/wordsize.h
... /usr/include/x86_64-linux-gnu/bits/typesizes.h
.. /usr/include/libio.h
... /usr/include/_G_config.h
.... /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h
.... /usr/include/wchar.h
... /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stdarg.h
.. /usr/include/x86_64-linux-gnu/bits/stdio_lim.h
.. /usr/include/x86_64-linux-gnu/bits/sys_errlist.h
在每行开头的点算嵌套有多深的的#include
是
这篇关于我如何才能找到在Linux下C编程语言的头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!