C compile time
Wolfgang Bangerth
bangerth@ices.utexas.edu
Wed Jun 18 18:57:00 GMT 2003
> > > How much of this is because anonymous namespaces are not marking their
> > > contents as static?
> >
> > Even if they did, I don't think it would be a big thing. Most functions
> > in C++ should be member functions, and then they can't be static.
>
> That's not true. If defined in an anonymous namespace, the member
> functions are not directly accessable to other translation units, thus the
> symbols would be marked private. Anonymous namespaces effectively make
> them static, it's just that the optimizer is not currently able to take
> advantage of this piece of semantic information...
Yes, yes, I understand that :-) It's just an observation that not a whole lot
of code is being placed into anonymous namespaces, whether it being functions
are whole classes.
As an analogy: Where in C you would have the functions implementing an
internal interface to some data structure as static functions, they would
most likely be private/protected member functions of a class in C++, but if
that class has also a public interface (the usual case), then the class
cannot be part of an anonymous namespace.
Or do you mean you want to place the implementation of a member functions of a
publicly visible class into an anonymous namespace? That would strike me as a
particularly bad and error-prone style...
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ices.utexas.edu
www: http://www.ices.utexas.edu/~bangerth/
More information about the Gcc
mailing list