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

Lenard Mollenkopf newlib@lenardmollenkopf.de
Tue Apr 22 21:48:13 GMT 2025


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>
---
Hi All, hi Corinna,
by now glibc supports _ISOC2Y_SOURCE. I now use __STDC_VERSION__ > 202311L,
as the previous >= 202400L is not standardized.

I am unsure what you, Corinna, ment by _GNU_SOURCE should result 
in _ISOC2Y_SOURCE being defined as well. This is done further up and
also works when tested.

 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 325acdf5f..60f062a1c 100644
--- a/newlib/libc/include/sys/features.h
+++ b/newlib/libc/include/sys/features.h
@@ -93,6 +93,9 @@ extern "C" {
  * _ISOC23_SOURCE or _ISOC2X_SOURCE or gcc -std=c23 or g++ -std=c++20
  *	ISO C23
  *
+ * _ISOC2y_SOURCE or gcc -std=c2y or g++ -std=c++26
+ *	ISO C2y
+ *
  * _ATFILE_SOURCE (implied by _POSIX_C_SOURCE >= 200809L)
  *	"at" functions
  *
@@ -129,6 +132,8 @@ extern "C" {
 #define	_ISOC11_SOURCE		1
 #undef _ISOC23_SOURCE
 #define	_ISOC23_SOURCE		1
+#undef _ISOC2Y_SOURCE
+#define	_ISOC2Y_SOURCE		1
 #undef _POSIX_SOURCE
 #define	_POSIX_SOURCE		1
 #undef _POSIX_C_SOURCE
@@ -239,6 +244,11 @@ extern "C" {
  *	g++ -std=c++20 or newer, or with
  *	_ISOC23_SOURCE or _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.
@@ -285,7 +295,10 @@ extern "C" {
 #define	__GNU_VISIBLE		0
 #endif
 
-#if defined(_ISOC23_SOURCE) || \
+#if defined(_ISOC2Y_SOURCE) || \
+  (__STDC_VERSION__ - 0) > 202311L || (__cplusplus - 0) > 202002
+#define __ISO_C_VISIBLE		2024
+#elif defined(_ISOC23_SOURCE) || \
   (__STDC_VERSION__ - 0) > 201710L || (__cplusplus - 0) >= 202002L
 #define __ISO_C_VISIBLE		2020
 #elif defined(_ISOC11_SOURCE) || \
-- 
2.49.0



More information about the Newlib mailing list