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

时间:2022-02-21 15:07:44

This header file shall define NULL or size_t and other macros, but I find that /usr/include/linux/stddef.h is empty? Why?

这个头文件应该定义NULL或size_t和其他宏,但是我发现/usr/ include/linux/stddef。h是空的吗?为什么?

1 个解决方案

#1


11  

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:

头的实际位置是实现定义的。你所看到的不是典型的 。h >包括gcc。你可以找到它在你的系统上的确切位置:

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

which is equivalent to including the header <stddef.h> in an empty C file and running gcc -E on it.

这相当于包括头 。在一个空的c文件中,运行gcc>

The headers in /usr/include/linux are used to compile the C library (usually glibc on Linux). The GNU manual says:

在/usr/include/linux中的头文件被用来编译C库(通常是Linux上的glibc)。GNU手册说:

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’.

linux、asm和asm-通用目录都需要使用GNU C库来编译程序;其他目录描述了内核的接口,但如果不使用这些接口编译程序,则不需要这样做。如果您没有使用“-with-header”指定一个备用的内核头源代码,那么您不需要复制内核头。

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:

而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

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.

底线是,这不是stddef。你对标准头文件的位置不应该做任何假设。

#1


11  

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:

头的实际位置是实现定义的。你所看到的不是典型的 。h >包括gcc。你可以找到它在你的系统上的确切位置:

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

which is equivalent to including the header <stddef.h> in an empty C file and running gcc -E on it.

这相当于包括头 。在一个空的c文件中,运行gcc>

The headers in /usr/include/linux are used to compile the C library (usually glibc on Linux). The GNU manual says:

在/usr/include/linux中的头文件被用来编译C库(通常是Linux上的glibc)。GNU手册说:

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’.

linux、asm和asm-通用目录都需要使用GNU C库来编译程序;其他目录描述了内核的接口,但如果不使用这些接口编译程序,则不需要这样做。如果您没有使用“-with-header”指定一个备用的内核头源代码,那么您不需要复制内核头。

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:

而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

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.

底线是,这不是stddef。你对标准头文件的位置不应该做任何假设。