[Bug libstdc++/107008] Combine config/os/*/error_constants.h into one file

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 22 10:44:12 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107008

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---

A related topic is that we simply don't define the errc enumerators that don't
have a corresponding EXXXX macro, which is non-conforming. The C++ standard
says the enumerators should all be there.

We could do something like this for each enumerator:

#ifdef EFOO
   foo = EFOO,
#else
   foo = _GLIBCXX_ERRC_ORIGIN + __LINE__,
#endif


Where _GLIBCXX_ERRC_ORIGIN is some value intended to be higher than the highest
errno value on the OS. We only need fewer than 100 errc enumerators so
INT_MAX/2 might be OK.

We can use #line to set the __LINE__ to a fixed value in the file, so that the
constants don't change if we add/remove lines before the errc definition.


More information about the Gcc-bugs mailing list