https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100286
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:9ee35a8685ee174c6914059143aceb7009d3e920 commit r12-153-g9ee35a8685ee174c6914059143aceb7009d3e920 Author: Jonathan Wakely <jwak...@redhat.com> Date: Tue Apr 27 13:06:43 2021 +0100 libstdc++: Better preprocessor conditions in net::ip [PR 100286] This improves the use of preprocessor conditionas to enable/disable members of namespace net::ip according to what is supported by the target. This fixes PR 100286 by ensuring that the to_string member functions are always defined for the address_v4 and address_v6 classes. On the other hand, the IP protocol classes and internet socket option classes aren't useful at all if the corresponding constants (such as IPPROTO_TCP or IPV6_MULTICAST_HOPS) aren't define. So those types are not defined at all if they can't be used. The net/internet/socket/opt.cc test uses __has_include to check whether or not to expect the types to be available. libstdc++-v3/ChangeLog: PR libstdc++/100286 * include/experimental/internet (resolver_errc, resolver_category()) (make_error_code, make_error_condition): Define unconditionally, only make enumerators and use of gai_strerror depend on the availability of <netdb.h>. (address_v4::to_string): Use correct constant for string length. (address_v4::to_string, address_v6::to_string): Define unconditionally, throw if unsupported. (make_address_v4, make_address_v6): Define unconditionally. Return an error if unsupported. (tcp, udp, v6_only, unicast::hops, multicast::*): Define conditionally, * testsuite/experimental/net/internet/socket/opt.cc: Check for <netinet/in.h> and <netinet/tcp.h> before using types from namespace net::ip.