为什么/usr/include/linux/stddef.h是空的? [英] Why /usr/include/linux/stddef.h is empty?

查看:1551
本文介绍了为什么/usr/include/linux/stddef.h是空的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个头文件应确定 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)。该 GNU手动说:

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-头。

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的,它有:

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是空的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆