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

相关文章

在Linux上编写运行C语言程序,经常会遇到程序崩溃、卡死等异...
git使用小结很多人可能和我一样,起初对git是一无所知的。我...
1. 操作系统环境、安装包准备 宿主机:Max OSX 10.10.5 虚拟...
因为业务系统需求,需要对web服务作nginx代理,在不断的尝试...
Linux模块机制浅析 Linux允许用户通过插入模块,实现干预内核...
一、Hadoop HA的Web页面访问 Hadoop开启HA后,会同时存在两个...