Re: improving C++ libc headers

Dimitry Andric <[email protected]>
Newsgroups gmane.os.freebsd.architechture
Message-ID <[email protected]>
On 31 Jan 2024, at 05:03, Mark Millard <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.