[PATCH v2 4/5] kbuild: uapi: provide a C++ compatible dummy definition of NULL

Thomas Weißschuh posted 5 patches 3 weeks ago
[PATCH v2 4/5] kbuild: uapi: provide a C++ compatible dummy definition of NULL
Posted by Thomas Weißschuh 3 weeks ago
NULL works differently in C++ compared to C.

To allow testing the UAPI headers against C++ compilers, provide
a variant of NULL which works with those.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
---
 usr/dummy-include/stddef.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usr/dummy-include/stddef.h b/usr/dummy-include/stddef.h
index a61703d1c896..525489daffe2 100644
--- a/usr/dummy-include/stddef.h
+++ b/usr/dummy-include/stddef.h
@@ -3,6 +3,11 @@
 #define _DUMMY_STDDEF_H
 
 #define offsetof(TYPE, MEMBER)	__builtin_offsetof(TYPE, MEMBER)
+
+#ifdef __cplusplus
+#define NULL 0
+#else
 #define NULL ((void *)0)
+#endif
 
 #endif /* _DUMMY_STDDEF_H */

-- 
2.53.0