这个头文件应该定义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,一般来说,你不应该对标准头文件的位置做任何假设.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。