This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Namespace question
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "Gabriel F. T. Gomes" <gftg at linux dot vnet dot ibm dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Thu, 9 Mar 2017 03:19:11 +0000
- Subject: Re: Namespace question
- Authentication-results: sourceware.org; auth=none
- References: <20170308234950.1cc86213@keller>
On 9 March 2017 at 02:49, Gabriel F. T. Gomes wrote:
> Hi,
>
> While working on a refactoring in glibc's libm, I came across a
> question about namespace for some helper functions in math.h.
>
> Each classification macro in math.h, has a type-specific helper
> function, for instance __fpclassifyf for float. We would like to
> understand if these functions need to be in a namespace or if, since
> they are helper functions, the namespace requirement does not apply.
>
> For instance, is the namespace code in the examples below correct,
> required, or even incorrect?
>
> namespace __c99 {
> extern int __fpclassifyf (float __value);
> extern int __signbit (double __value);
> extern int __isinff (float __value);
> }
>
> namespace std {
> extern int __isinf (double __value);
> }
Libstdc++ doesn't use any of these functions. You can use whatever
private namespaces you want for internal glibc functions.
I would recommend against adding any non-standard functions to
namespace std in the C library headers. The C++ library owns that
namespace and littering it with non-standard names defined outside the
C++ library doesn't seem wise.