为什么/usr/include/linux/stddef.h为空?

这个头文件应该定义NULL或者size_t等宏,但是我发现/usr/include/ linux/stddef.h是空的?为什么? 标头的实际位置是实现定义的.你看的不是典型的 stddef.h由gcc包含您可以通过以下方式找出系统所在的位置: gcc -E – #includestddef.h | grep stddef.h 这相当

这个头文件应该定义NULL或者size_t等宏,但是我发现/usr/include/
linux/stddef.h是空的?为什么?

解决方法

标头的实际位置是实现定义的.你看的不是典型的< stddef.h>由gcc包含您可以通过以下方式找出系统所在的位置:

gcc -E - <<<'#include<stddef.h>' | grep stddef.h

这相当于包括标题< stddef.h>在一个空的C文件中并运行gcc -E.

/usr/include / linux中的标头用于编译C库(通常是Linux上的glibc). GNU manual说:

The linux,asm and asm-generic directories are required to
compile programs using the GNU C Library; the other directories
describe interfaces to the kernel but are not required if not
compiling programs using those interfaces. You do not need to copy
kernel headers if you did not specify an alternate kernel header
source using ‘–with-headers’.

而C库头文件通常位于/usr/lib /中的某个位置.在我的ubuntu 15.04上,头文件/usr/include/linux/stddef.h为空.但是在我的CentOS上,它有:

#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,一般来说,你不应该对标准头文件的位置做任何假设.

作者: dawei

【声明】:西安站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部