Talk:c/types/NULL
From cppreference.com
Err, your article says that the macro is defined in stddef.h, string.h, wchar.h, time.h, locale.h and stdio.h, yet the subsequent example uses this constant while #including only stdlib.h. Is this example 100% standard conformant? Shouldn't it #include more headers? Or perhaps stdlib.h does define NULL as well, only this article fails to mention that? (this would be hinted by http://www.cplusplus.com/reference/cstdlib/NULL/ , although I'm not sure if this is not only relevant for C++)
- good catch. In C, NULL is defined in 7 headers: locale.h stddef.h stdio.h stdlib.h string.h time.h wchar.h. In C++, NULL is explicitly defined in 6 headers: clocale cstddef cstdio cstring ctime cwchar. However, although it is missing from the table describing the contents of cstdlib (§18.5[support.start.term]/1), the standard says that the table "describes some of the contents of the header" and further "The contents are the same as the Standard C library header <stdlib.h>", which means cstdlib also must define NULL. This page was initially written for C++ and then copied to the C side of the wiki, bringing over the omission. --Cubbi (talk) 06:12, 16 December 2015 (PST)
- C++11's Table 149 doesn't list
NULL <cstdio>. Is this a bug in the Standard? --D41D8CD98F (talk) 08:35, 16 December 2015 (PST)
- C++11's Table 149 doesn't list