From a7239cbc1bc4144eb34e0b85f71769f0acda58dd Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 26 Feb 2024 09:37:44 -0500 Subject: [PATCH] switch __STDC_UTF_{16,32}__ macro definitions from #undef to #ifndef originally, compilers did not provide these macros and we had to provide them ourselves. this meant we were redefining them, which was technically invalid unless the token sequence of the original definition matched exactly. the original patch proposed by Jules Maselbas to fix this made the definitions conditional on them not already being defined; however I suggested using #undef to avoid any possibly-wrong definitions already in place and ensure that the definitions are 1. the version adopted as commit 8b7048680731707d135ea231f81eb3eaf52378ee made this change. unfortunately, gcc is loud about not liking #undef of any __STDC_* macro name, and while warnings are suppressed in the system include path, there is apparently no way to suppress this warning if the system include dir has also been provided via -I. while normally we don't go out of our way to satisfy warnings over style in the public headers, in this case, it seems to be a matter of disagreement over contract of which part of "the implementation" is entitled to define or undefine macros belonging to the implementation, and it's quite reasonable to conclude that the compiler may reject attempts to undefine them. this commit reverts to the originally-submitted version of the patch making the definitions conditional. --- include/stdc-predef.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/stdc-predef.h b/include/stdc-predef.h index 5ccd884d..642bad2d 100644 --- a/include/stdc-predef.h +++ b/include/stdc-predef.h @@ -7,10 +7,12 @@ #define __STDC_IEC_559__ 1 #endif -#undef __STDC_UTF_16__ +#if !defined(__STDC_UTF_16__) #define __STDC_UTF_16__ 1 +#endif -#undef __STDC_UTF_32__ +#if !defined(__STDC_UTF_32__) #define __STDC_UTF_32__ 1 +#endif #endif