Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jan 2016 03:27:32 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        bugzilla-noreply@freebsd.org
Cc:        freebsd-standards@freebsd.org
Subject:   Re: [Bug 206146] fileno(3) should be implemented as a function; need to check other functions as well
Message-ID:  <20160113024328.O3284@besplex.bde.org>
In-Reply-To: <bug-206146-15-rTJ61vuJO5@https.bugs.freebsd.org/bugzilla/>
References:  <bug-206146-15@https.bugs.freebsd.org/bugzilla/> <bug-206146-15-rTJ61vuJO5@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 12 Jan 2016 bugzilla-noreply@freebsd.org wrote:

> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206146
>
> --- Comment #4 from David Chisnall <theraven@FreeBSD.org> ---
> Bruce, almost none of what you have said is relevant for C++.

The user or implementation is including <stdio.h> without understanding
its namespace and getting full pollution with POSIX support and
FreeBSD extensions.

I don't want to know about C++, but looked at the implementations in
<c++>.  These only know about the C90 (and maybe C99) function-like
APIs that are required to exist as macros.  These are handled by
#undefing them all.

Extensions should be handled by #defining _ANSI_SOURCE, _C99_SOURCE or
_C11_SOURCE before including <stdio.h>.  <stdio.h> only has a tiny amount
of direct support for C++ (mainly __BEGIN_DECLS, etc.).

The c++  is also broken for most or all standard function-like
APIs that are not required to be macros.  These are permitted to be
implemented using (safe) macros.  #undefing all of these or knowing
which ones need to be #undefed takes more understanding of the C
namespace than defining _XXX_SOURCE.

gcc handled this better in 2003 or earlier.  <c++/3.3/cstdio>
unconditionally #undef's all (?) 41 of the standard C90 function-like
APIs before reusing them in 'namespace std'.  Later it does the
same for all (?) 5 extensions in C99.  It doesn't seem to do anything
for POSIX extensions and I doubt that this is handled automatically.
Any pre-definitions of _XXX_SOURCE would hide POSIX and FreeBSD
extensions in all C headers.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160113024328.O3284>