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 8b70486807 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.
This commit is contained in:
Rich Felker 2024-02-26 09:37:44 -05:00
parent 2c887f24da
commit a7239cbc1b

View File

@ -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