about summary refs log tree commit diff
path: root/include/locale.h
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-11-24 21:42:55 -0500
committerRich Felker <dalias@aerifal.cx>2013-11-24 21:42:55 -0500
commitc8a9c22173f485c8c053709e1dfa0a617cb6be1a (patch)
tree6e09d7e73bbff957b45370d412cc6299fe51eb37 /include/locale.h
parent7e771e62e78944b9d1fe7e78ef71422b9d51f275 (diff)
downloadmusl-c8a9c22173f485c8c053709e1dfa0a617cb6be1a.tar.gz
musl-c8a9c22173f485c8c053709e1dfa0a617cb6be1a.tar.xz
musl-c8a9c22173f485c8c053709e1dfa0a617cb6be1a.zip
restore type of NULL to void * except when used in C++ programs
unfortunately this eliminates the ability of the compiler to diagnose
some dangerous/incorrect usage, but POSIX requires (as an extension to
the C language, i.e. CX shaded) that NULL have type void *. plain C
allows it to be defined as any null pointer constant.

the definition 0L is preserved for C++ rather than reverting to plain
0 to avoid dangerous behavior in non-conforming programs which use
NULL as a variadic sentinel. (it's impossible to use (void *)0 for C++
since C++ lacks the proper implicit pointer conversions, and other
popular alternatives like the GCC __null extension seem non-conforming
to the standard's requirements.)
Diffstat (limited to 'include/locale.h')
-rw-r--r--include/locale.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/locale.h b/include/locale.h
index 7e80fd93..ce384381 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -7,7 +7,11 @@ extern "C" {
 
 #include <features.h>
 
+#ifdef __cplusplus
 #define NULL 0L
+#else
+#define NULL ((void*)0)
+#endif
 
 #define LC_CTYPE    0
 #define LC_NUMERIC  1