This header file shall define NULL
or size_t
and other macros, but I find that /usr/include/linux/stddef.h
is empty? Why?
The stddef. h header file is located in /usr/lib/gcc/x86_64-redhat-linux/3.4. 2/include so if the “GCCINC” directory is not set correctly, it wont be able to find the file.
h is a header file in the standard library of the C programming language that defines the macros NULL and offsetof as well as the types ptrdiff_t, wchar_t, and size_t.
These files are needed when you compile programs, be that a software package you need to compile manually or your own programs. They are included in the C code such that you can use the functions defined there. Don't worry about them if you don't code. Save this answer.
They are very different; the /usr/include/linux headers are the headers that were used when compiling the system's standard C library. They are owned by the C library packaging, and updated in lockstep with the standard C library.
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
which is equivalent to including the header <stddef.h>
in an empty C file and running gcc -E
on it.
The headers in /usr/include/linux
are used to compile the C library (usually glibc on Linux). The GNU manual says:
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’.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With