[PATCH] sys/features.h: Define _ISOC2Y_SOURCE and __ISO_C_VISIBLE

Lenard Mollenkopf newlib@lenardmollenkopf.de
Tue Oct 29 14:34:46 GMT 2024


Add feature test for C2Y code. Add matching definitions
_ISOC2Y_SOURCE for requesting sources and __ISO_C_VISIBLE
to be used in headers.

Signed-off-by: Lenard Mollenkopf <newlib@lenardmollenkopf.de>
---
 newlib/libc/include/sys/features.h | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h
index 00c3bba9c..3fc5d87a7 100644
--- a/newlib/libc/include/sys/features.h
+++ b/newlib/libc/include/sys/features.h
@@ -93,6 +93,9 @@ extern "C" {
  * _ISOC2x_SOURCE or gcc -std=c2x or g++ -std=c++20
  *	ISO C2x
  *
+ * _ISOC2y_SOURCE or gcc -std=c2y or g++ -std=c++26
+ *	ISO C2y
+ *
  * _ATFILE_SOURCE (implied by _POSIX_C_SOURCE >= 200809L)
  *	"at" functions
  *
@@ -122,6 +125,8 @@ extern "C" {
 #define	_ISOC11_SOURCE		1
 #undef _ISOC2X_SOURCE
 #define	_ISOC2X_SOURCE		1
+#undef _ISOC2Y_SOURCE
+#define	_ISOC2Y_SOURCE		1
 #undef _POSIX_SOURCE
 #define	_POSIX_SOURCE		1
 #undef _POSIX_C_SOURCE
@@ -232,6 +237,11 @@ extern "C" {
  *	g++ -std=c++20 or newer, or with
  *	_ISOC2X_SOURCE.
  *
+ * __ISO_C_VISIBLE >= 2024
+ *	ISO C2y; enabled with gcc -std=c2y or newer,
+ *	g++ -std=c++26 or newer, or with
+ *	_ISOC2y_SOURCE.
+ *
  * __ATFILE_VISIBLE
  *	"at" functions; enabled by default, with _ATFILE_SOURCE,
  *	_POSIX_C_SOURCE >= 200809L, or _XOPEN_SOURCE >= 700.
@@ -278,7 +288,10 @@ extern "C" {
 #define	__GNU_VISIBLE		0
 #endif
 
-#if defined(_ISOC2X_SOURCE) || \
+#if defined(_ISOC2Y_SOURCE) || \
+  (__STDC_VERSION__ - 0) >= 202400L || (__cplusplus - 0) >= 202400L
+#define __ISO_C_VISIBLE		2024
+#elif defined(_ISOC2X_SOURCE) || \
   (__STDC_VERSION__ - 0) > 201710L || (__cplusplus - 0) >= 202002L
 #define __ISO_C_VISIBLE		2020
 #elif defined(_ISOC11_SOURCE) || \
-- 
2.47.0



More information about the Newlib mailing list