MESSAGE
DATE | 2011-06-05 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] (fwd) Re: Anonymous namespace
|
-- forwarded message -- Path: reader1.panix.com!panix!bloom-beacon.mit.edu!micro-heart-of-gold.mit.edu!nntp.club.cc.cmu.edu!feeder.erje.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: Anonymous namespace Date: Fri, 03 Jun 2011 20:17:24 +1200 Lines: 23 Message-ID: <94rjklFbjiU8-at-mid.individual.net> References: <03464db0-e118-463c-9834-171dab457e42-at-h9g2000yqk.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net bXhtfQbD0FsmsrQvCv8c4wWxecGV/Xv51m0ElTE3ryq94x0vvG Cancel-Lock: sha1:sdjP/SxUaaGGgKPfncS26Y6E7ng= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: <03464db0-e118-463c-9834-171dab457e42-at-h9g2000yqk.googlegroups.com> Xref: panix comp.lang.c++:1085959
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.
-- Ian Collins -- end of forwarded message --
|
|