This is the mail archive of the
mailing list for the GCC project.
Re: Anonymous Namespaces
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Kevin Atkinson <kevina at gnu dot org>
- Cc: Andrew Pinski <pinskia at physics dot uc dot edu>, gcc at gcc dot gnu dot org
- Date: 31 Jan 2004 11:14:53 +0100
- Subject: Re: Anonymous Namespaces
- Organization: Integrable Solutions
- References: <Pine.LNX.email@example.com>
Kevin Atkinson <firstname.lastname@example.org> writes:
| On Sat, 31 Jan 2004, Andrew Pinski wrote:
| > On Jan 31, 2004, at 01:40, Kevin Atkinson wrote:
| > > So, is there a reason there not? If so, is there a way to declare
| > > member
| > > functions as having static linkage so that the unit-at-a-time code can
| > > optimize them.
| > Yes because that is not the way C++ works, anonymous namespaces only
| > give an unique name for that translation unit and that is it; it does
| > not change the linkage of the symbol at all.
| Is there any harm is doing so?
Yes. The second phase of two-phase name lookup ignores functions with
internal linkages. Also, entities with internal linkage cannot be
used as template arguments.
| There is no way for the symbol defined in
| an anonymous namespace to be used outside if the translation unit. It
| should have the same effect as static. The new unit-at-a-time optimizations
| will be a lot more beneficial in C++ programs is anonymous namespaces were
| treated that way.
If you're having trouble with unit-at-a-time not recognizing functions
in unnamed namespacen, then the right course of action to do is to teach
that programmed inliner to recognize those functions. Asking for
deviating from standard semantics is wrong.