This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Namespace question


On 9 March 2017 at 15:04, Joseph Myers wrote:
> On Thu, 9 Mar 2017, Jonathan Wakely wrote:
>
>> N.B. libstdc++ removed the last mention of _GLIBCXX_USE_NAMESPACES in
>> 2000, so we don't really care what glibc does with namespaces. We
>> don't use them.
>
> So we should remove all uses of __BEGIN_NAMESPACE_STD __END_NAMESPACE_STD
> __USING_NAMESPACE_STD __BEGIN_NAMESPACE_C99 __END_NAMESPACE_C99
> __USING_NAMESPACE_C99 from glibc headers?

Doing so wouldn't hurt libstdc++.

I don't know the history behind _GLIBCPP_USE_NAMESPACES or why we
stopped using it, but it looks like something that existed in the GCC
2.95 era. Setting the macro in libstdc++ headers was removed as part
of the same commit as
https://gcc.gnu.org/ml/libstdc++/2000-q2/msg00308.html but with a
separate ChangeLog entry, see https://gcc.gnu.org/r33835
I can't find an email to the list about this part of the change:

        via Phil Edwards  <pme@sourceware.cygnus.com>
        * bits/std_cctype.h: Remove _GLIBCPP_USE_NAMESPACES.
        * acconfig.h: And here.
        * acinclude.m4: Same.
        * testsuite/27_io/istream.cc: And here.
        * testsuite/27_io/ostream.cc: And here.

In theory it might be nice if glibc added names to namespace std (we
could avoid problems like
https://gcc.gnu.org/ml/gcc-help/2017-03/msg00011.html) but I don't see
how it can work unless the C++ library provides shadow headers for
every C header, so that it can ensure _GLIBCPP_USE_NAMESPACES is
defined before any glibc header is included. I think C library headers
adding "namespace std" can only work if it's done unconditionally, not
how glibc does it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]