diff options
author | Ismael Luceno <ismael@iodev.co.uk> | 2021-08-15 17:51:57 +0200 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2021-11-29 17:45:21 -0500 |
commit | 98e688a9da5e7b2925dda17a2d6820dddf1fb287 (patch) | |
tree | 5ed7c1b59b7688980996dfb6a2954e1b8b53bf70 | |
parent | 8274aaaaa1948c50c661aa32e21b3db27a5c0eab (diff) | |
download | musl-98e688a9da5e7b2925dda17a2d6820dddf1fb287.tar.gz musl-98e688a9da5e7b2925dda17a2d6820dddf1fb287.tar.xz musl-98e688a9da5e7b2925dda17a2d6820dddf1fb287.zip |
define NULL as nullptr when used in C++11 or later
This should be safer for casting and more compatible with existing code bases that wrongly assume it must be defined as a pointer.
-rw-r--r-- | include/locale.h | 4 | ||||
-rw-r--r-- | include/stddef.h | 4 | ||||
-rw-r--r-- | include/stdio.h | 4 | ||||
-rw-r--r-- | include/stdlib.h | 4 | ||||
-rw-r--r-- | include/string.h | 4 | ||||
-rw-r--r-- | include/time.h | 4 | ||||
-rw-r--r-- | include/unistd.h | 4 | ||||
-rw-r--r-- | include/wchar.h | 4 |
8 files changed, 24 insertions, 8 deletions
diff --git a/include/locale.h b/include/locale.h index ce384381..11106fea 100644 --- a/include/locale.h +++ b/include/locale.h @@ -7,7 +7,9 @@ extern "C" { #include <features.h> -#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) #define NULL 0L #else #define NULL ((void*)0) diff --git a/include/stddef.h b/include/stddef.h index bd753853..f25b8639 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -1,7 +1,9 @@ #ifndef _STDDEF_H #define _STDDEF_H -#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) #define NULL 0L #else #define NULL ((void*)0) diff --git a/include/stdio.h b/include/stdio.h index 3604198c..d1ed01f0 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -25,7 +25,9 @@ extern "C" { #include <bits/alltypes.h> -#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) #define NULL 0L #else #define NULL ((void*)0) diff --git a/include/stdlib.h b/include/stdlib.h index 7af86e3b..b507ca33 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -7,7 +7,9 @@ extern "C" { #include <features.h> -#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) #define NULL 0L #else #define NULL ((void*)0) diff --git a/include/string.h b/include/string.h index 795a2abc..43ad0942 100644 --- a/include/string.h +++ b/include/string.h @@ -7,7 +7,9 @@ extern "C" { #include <features.h> -#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) #define NULL 0L #else #define NULL ((void*)0) diff --git a/include/time.h b/include/time.h index 5494df18..3d948372 100644 --- a/include/time.h +++ b/include/time.h @@ -7,7 +7,9 @@ extern "C" { #include <features.h> -#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) #define NULL 0L #else #define NULL ((void*)0) diff --git a/include/unistd.h b/include/unistd.h index 13064026..ee2dbe8a 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -15,7 +15,9 @@ extern "C" { #define SEEK_CUR 1 #define SEEK_END 2 -#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) #define NULL 0L #else #define NULL ((void*)0) diff --git a/include/wchar.h b/include/wchar.h index 88eb55b1..ed5d774d 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -38,7 +38,9 @@ extern "C" { #define WCHAR_MIN (-1-0x7fffffff+L'\0') #endif -#ifdef __cplusplus +#if __cplusplus >= 201103L +#define NULL nullptr +#elif defined(__cplusplus) #define NULL 0L #else #define NULL ((void*)0) |