Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 19 Apr 2023 08:42:15 +0200
From: Jens Gustedt <Jens.Gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: [C23 divers headers 16/17] C23: add the nullptr_t type

This will only work with compilers that implement typeof and
nullptr. Currently this doesn't work for gcc but this will probably be
in gcc-13. Therefore the version test uses the future date of 202311L
which is the foreseen value for C23 final.

For clang there are better feature test macros, namely
__is_identifier(nullptr) can be used to test if nullptr is an
identifier or a keyword. In particular, this feature now seems to work
with clang 16.0.2.
---
 include/stddef.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/stddef.h b/include/stddef.h
index 09be5fb6..e4d6b2ef 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -26,4 +26,14 @@
 
 #define unreachable() __builtin_unreachable()
 
+#if __STDC_VERSION__ >= 202311L
+typedef typeof(nullptr) nullptr_t;
+#else
+#if __clang__
+#if !__is_identifier(nullptr)
+typedef typeof(nullptr) nullptr_t;
+#endif
+#endif
+#endif
+
 #endif
-- 
2.34.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.