Re: improving C++ libc headers
- In reply to: Mark Millard : "RE: improving C++ libc headers "
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 31 Jan 2024 08:57:50 UTC
On 31 Jan 2024, at 05:03, Mark Millard <marklmi@yahoo.com> wrote: > > Lexi Winter <lexi_at_le-fay.org> wrote on > Date: Tue, 30 Jan 2024 13:30:54 UTC : > >> i am considering working up a patch to improve C++ libc headers in FreeBSD. >> >> the problem with the current headers (which come from clang/libc++) is >> that this code compiles: >> >> ------ >> #include <cstdlib> >> auto main() -> int { >> exit(0); >> } >> ------ >> >> this should be a compile-time error, because <cstdio> does not declare >> ::exit[0]. however, it works because <cstdlib> is implemented like >> this: > > While I like the removal of header pollution, various > C++ standard vintages have explicit wording that it is > not an error for "C++ headers for C library facilities" > (the for-C ones that are <c...> named) to be this way: > > QUOTE of an example: > It is unspecified whether these names (. . .) are first > declared in the global namespace scope and are then > injected into namespace std by explicit using-declarations. > END QUOTE Yeah, this is completely unrealistic, and will break a huge amount of programs for little gain. -Dimitry