MESSAGE
DATE | 2011-06-05 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] (fwd) Re: Anonymous namespace
|
-- forwarded message -- Path: reader1.panix.com!panix!not-for-mail From: Ruben Safir Newsgroups: comp.lang.c++ Subject: Re: Anonymous namespace Date: Sat, 4 Jun 2011 05:08:06 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 27 Message-ID: References: <03464db0-e118-463c-9834-171dab457e42-at-h9g2000yqk.googlegroups.com> <94rjklFbjiU8-at-mid.individual.net> NNTP-Posting-Host: www2.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reader1.panix.com 1307164086 20952 96.57.23.82 (4 Jun 2011 05:08:06 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Sat, 4 Jun 2011 05:08:06 +0000 (UTC) X-Blackjet: Blackjet is a Yankee Fan X-DRMisTHEFT: Use GNU Linux today X-From: A Dark Cloud X-LOCATION: Brooklyn NY - Forget abou' it! X-NYLXS: Really - yah think computers are supposed to be broken? User-Agent: Pan/0.133 (House of Butterflies) Xref: panix comp.lang.c++:1086005
On Fri, 03 Jun 2011 20:17:24 +1200, Ian Collins wrote:
> On 06/ 3/11 08:08 PM, gwowen wrote: >> On Jun 3, 3:54 am, r...-at-zedat.fu-berlin.de (Stefan Ram) wrote: >>>> What is the point of the anonymous namespace. >>> >>> Names can be hidden from the linker (from other translation units), >>> even if they should have external linkage. >> >> Can someone give the benefits of external-but-unlinkable anon- >> namespace variables (or functions) against old-school internal linkage >> file-scope "static" variables and functions. > > I guess the most common (at least in my case) use is to declare > different classes with a common name in multiple source files. I have > lots of instances of > > namespace { > struct TestObject { .. }; > } > > in my unit test files.
YES - I can understand that. Then you can have one in each transitional unit. The problem arises when you #include two of them from different files. -- end of forwarded message --
|
|