MESSAGE
DATE | 2011-06-05 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] (fwd) Re: Anonymous namespace
|
-- forwarded message -- Path: reader1.panix.com!panix!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!hd10g2000vbb.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?=D6=F6_Tiib?= Newsgroups: comp.lang.c++ Subject: Re: Anonymous namespace Date: Fri, 3 Jun 2011 06:08:42 -0700 (PDT) Organization: http://groups.google.com Lines: 32 Message-ID: References: NNTP-Posting-Host: 212.47.207.1 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1307106522 7958 127.0.0.1 (3 Jun 2011 13:08:42 GMT) X-Complaints-To: groups-abuse-at-google.com NNTP-Posting-Date: Fri, 3 Jun 2011 13:08:42 +0000 (UTC) Complaints-To: groups-abuse-at-google.com Injection-Info: hd10g2000vbb.googlegroups.com; posting-host=212.47.207.1; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17 (.NET CLR 3.5.30729),gzip(gfe) Xref: panix comp.lang.c++:1085969
On Jun 3, 9:29=A0am, ruben safir wrote: > On 06/02/2011 10:54 PM, Stefan Ram wrote: > > >> >What is the point of the anonymous namespace. > > =A0 =A0Names can be hidden from the linker (from other translation > > =A0 =A0units), even if they should have external linkage. > > please expand?
The code like:
namespace { int i;
void foo() {/*...*/} }
Means that i and foo() are translation unit local. It was meant to replace code like:
static int i; static void foo() {/*...*/}
That is because you can not declare types as static in C++. Lot of things in C++ are done using types. You might still want to have translation unit local types and nameless namespace helps there.
To keep the style consistent the usage of the 'static' keyword in sense of 'translation unit local' was even deprecated by C++03 but i trust it will be not deprecated by C++11 again. C++ does not want to enforce style upon its users. -- end of forwarded message --
|
|