Browse Source

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.
Rich Felker 2 months ago
parent
commit
a7239cbc1b
1 changed files with 4 additions and 2 deletions
  1. 4 2
      include/stdc-predef.h

+ 4 - 2
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