The C standard requires that NULL be defined in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h, and wchar.h.

The C++ standard requires that NULL be defined in the c* header corresponding to each of those.

The C standard is very strict about the names a standard can define--each standard header must define precisely the names the standard requires that header to define. The only other names it can define are those that are reserved for the implementation, such as those starting with an underscore followed by another underscore or a capital letter.

The C++ standard is much more permissive in this respect--including any one standard header can have the same effect as including any or all other standard headers.

From a practical viewpoint, C++ implementations used to take quite a bit of advantage of this permissiveness--that is, including one standard header frequently defined the names from a number of other standard headers. More recent implementations tend to work more like the C standard requires, staying much closer to each header defining only the names required by to be defined by that header. They're still probably not as strict about it as the C standard requires, but much closer than they used to be (as a rule).

Answer from Jerry Coffin on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › c language › null-pointer-in-c
NULL Pointer in C - GeeksforGeeks
We just have to assign the NULL value. Strictly speaking, NULL expands to an implementation-defined null pointer constant which is defined in many header files such as “stdio.h”, “stddef.h”, “stdlib.h” etc.
Published   January 10, 2025
Discussions

Old compilers and NULL
NULL is a macro that should be defined in a header . In theory it's possible that some compiler ships without a definition for it (can anyone comment if there's a C standard where this is permitted?), in practice you've simply forgotten to include the right header. More on reddit.com
🌐 r/C_Programming
31
36
March 29, 2022
"In which header file NULL macro is defined ? "
The correct answer is option 1: stdio.h and stddef.h Key Points NULL is a macro representing a null pointer constant. It is defined as #define NULL ( More on testbook.com
🌐 testbook.com
1
1707
1 month ago
Which C standard header file defines NULL character? - Stack Overflow
Which C standard header file defines the symbolic constant for the NULL character (\0), which is the character used as string terminator? While I have defined it myself in the program as: #define More on stackoverflow.com
🌐 stackoverflow.com
c - Which windows.h header defines NULL? - Stack Overflow
I have to write some Windows code, and I want to separate it from the Linux part as much as possible. At one point I need to check for NULL in the Windows code, but I don't want to include stdio.h or More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › null-undeclared-error-in-c-c-and-how-to-resolve-it
NULL undeclared error in C/C++ and how to resolve it - GeeksforGeeks
July 15, 2025 - Assign 0: Instead of assigning ... 0. Below code shows its implementation: ... Include "stddef.h" Header file: In stddef.h header file NULL is already defined, so we can include this header file in our program and our program ...
🌐
GeeksforGeeks
geeksforgeeks.org › c language › difference-between-null-pointer-null-character-0-and-0-in-c-with-examples
Difference between NULL pointer, Null character ('\0') and '0' in C with Examples - GeeksforGeeks
July 15, 2025 - If any pointer is being compared ... to as a null pointer constant. The C standard defines that 0 is typecast to (void *) is both a null pointer and a null pointer constant. The macro NULL is provided in the header file "stddef.h"....
🌐
C-faq
c-faq.com › null › macro.html
Question 5.4
A: As a matter of style, many ... NULL is defined (by several headers, including <stdio.h> and <stddef.h>) as a null pointer constant, typically 0 or ((void *)0) (see also question 5.6)....
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › c-runtime-library › null-crt
NULL (CRT) | Microsoft Learn
October 26, 2022 - Feedback · Summarize this article ... 0. NULL is defined in the following header files: CRTDBG.H, LOCALE.H, STDDEF.H, STDIO.H, STDLIB.H, STRING.H, TCHAR.H, TIME.H and WCHAR.H....
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › c_standard_library › c_macro_null.htm
C library - NULL Macro
Following is the C library syntax of the NULL Macro. #define NULL ((char *)0) or, #define NULL 0L or #define NULL 0
🌐
Wikibooks
en.wikibooks.org › wiki › C_Programming › stddef.h
C Programming/stddef.h - Wikibooks, open books for an open world
November 1, 2007 - stddef.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[1].
🌐
Scaler
scaler.com › home › topics › what is null pointer in c?
What is Null Pointer in C? - Scaler Topics
September 4, 2023 - It just stores the segment's base address. That is, the null pointer in C holds the value Null, but the type of the pointer is void. A null pointer is a special reserved value declared in a header file called stddef.
🌐
Cprogramming
cboard.cprogramming.com › cplusplus-programming › 92384-null-not-defined.html
Null Not Defined
Hi, Sometimes when I use NULL the compiler spits out an error saying NULL is not defined. Could anyone tell me the reason (in general) why this would happen. Cheers Alex ... Because you haven't #include'd one of the header files (eg <stdlib.h> or <cstdlib>) that #define's NULL.
🌐
cppreference.com
en.cppreference.com › c › types › NULL
NULL - cppreference.com
A null pointer constant may be converted to any pointer type; such conversion results in the null pointer value of that type. ... POSIX requires NULL to be defined as an integer constant expression with the value 0 cast to void*.
🌐
Linux Man Pages
man7.org › linux › man-pages › man3 › null.3const.html
NULL(3const) - Linux manual page
C11, POSIX.1-2024. C89, POSIX.1-1988. The following headers also provide NULL: <locale.h>, <stdio.h>, <stdlib.h>, <string.h>, <time.h>, <unistd.h>, and <wchar.h>. It is undefined behavior to dereference a null pointer, and that usually causes a segmentation fault in practice.
🌐
TheJat
thejat.in › home › learn › os development › the c standard library › the stddef header file
The stddef Header File
It is defined in the <stddef.h> header in C and the <cstddef> header in C++. size_t is an unsigned integer type and is typically used for operations involving memory and array indexing where non-negative values are required.
🌐
C For Dummies
c-for-dummies.com › blog
Zero and NULL and Pointers and Stuff | C For Dummies Blog
April 17, 2021 - I’ve written before that the constant isn’t defined as zero, though such an assumption could lead you into trouble. Keep in mind that NULL is a defined constant. It’s declared in the stdio.h header file or, more likely, its definition is made in another header file that’s referenced ...