问题描述
这个头文件应确定 NULL
或为size_t
等宏,但我发现 /usr/include/linux/stddef.h
是空的?为什么呢?
This header file shall define NULL
or size_t
and other macros, but I find that /usr/include/linux/stddef.h
is empty? Why?
推荐答案
头的实际位置是实现定义。是什么你看不典型<&STDDEF.H GT;
包括GCC。你可以找出到底位于何处您的系统上:
The actual location of the headers is implementation defined. What you look at is not the typical <stddef.h>
included by gcc. You can find out exactly where it's located on your system with:
gcc -E - <<<'#include<stddef.h>' | grep stddef.h
这相当于包括头&LT; STDDEF.H&GT;
在一个空的C文件并运行的gcc -E
就可以了。
which is equivalent to including the header <stddef.h>
in an empty C file and running gcc -E
on it.
在的头文件在/ usr /在include / linux
用于编译C库(通常在Linux的glibc)。该说:
The headers in /usr/include/linux
are used to compile the C library (usually glibc on Linux). The GNU manual says:
在的Linux ASM 和 ASM-通用目录要求
编译使用GNU C库程序;其他目录
描述接口到内核,但如果没有不要求
编译使用这些接口程序。不需要复制
内核头文件,如果没有指定备用内核头
源用--with-头。
而C库头在通常放在某处由/ usr / lib目录/
。在我的Ubuntu 15.04,头文件 /usr/include/linux/stddef.h
是空的。但在我的CentOS的,它有:
whereas the C library headers are usually placed by somewhere in /usr/lib/
. On my ubuntu 15.04, the header /usr/include/linux/stddef.h
is empty. But on my CentOS, it has:
#ifndef _LINUX_STDDEF_H
#define _LINUX_STDDEF_H
#undef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
底线是,这不是 STDDEF.H
你有兴趣,并在一般情况下,你不应该做出标准头文件的位置做任何假设
The bottom line is, this is NOT the stddef.h
you are interested in and in general, you should not make any assumptions about the location of the standard header files.
这篇关于为什么/usr/include/linux/stddef.h是空的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!