Re: Synopsis Question
David Abrahams <[email protected]>
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
Stefan Seefeld <[email protected]> writes: > David Abrahams wrote: > >>>That's right, but that defeats the purpose of the anonymous namespace to >>>deliberately hide the symbols it declares from the outside. >> ?? >> I haven't been watching this thread carefully, but last time I checked >> anonymous namespaces don't hide anything from anybody. > > 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. > 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. -- Dave Abrahams Boost Consulting www.boost-consulting.com