Re: Re: Synopsis Question

Stefan Seefeld <[email protected]>
Newsgroups gmane.comp.documentation.synopsis
Message-ID <[email protected]>
David Abrahams wrote:

>>Huh ? Isn't an anonymous (or 'unnamed' as per the spec 7.3.1.1) namespace
>>specifically provided to avoid accidental ODR violations, 
> 
> 
> Well, if you use it in source (.cpp) files, yeah.  But then the symbol
> is hidden from other TUs because, well, it's not *present* in those
> TUs.  

It could, without the anonymous namespace, still be referenced ('forward declared')
as 'extern', and the linker would resolve it. With anonymous namespaces the
linker will complain.

>>i.e. to make symbols local to the file containing that anonymous
>>namespace ?
> 
> 
> Yeah, but that doesn't prevent ODR violations by itself.  If you use
> the unnamed namespace in a header it's as likely as not to *cause* ODR
> violations, indirectly, when a template uses the symbols.

You are right. I'v never used it in headers, and in fact, I don't quite
understand what the purpose would be to put it into a header (see
http://synopsis.fresco.org/issues/bug32 for example).

Regards,
		Stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.