Alex Rivera | Logout

unnamed namespace

Asked 2010-11-18T09:26:56.990
14

What does it exactly mean when the Standard states

$7.3.1.1/2 - "The use of the static keyword is deprecated when declaring variables in a namespace scope (see annex D); the unnamed-namespace provides a superior alternative."

I have referred this but it does not cover what I am looking for.

Is there an example where the superiority is clearly demonstrated.

NB: I know about how unnamed namespaces can make extern variables visible in the translation unit and yet hide them from other translation units. But the point of this post is about 'static namespace scope' names (e.g global static variables)

Edit
Report

1 Answer

6

Interestingly, ISO/IEC 14882:2011 (C++11) removed this language (in fact, it removes the whole paragraph §7.3.1.1/2). It also removes the mention of static from Annex D.

Thus, using the storage class specifier static to give a name internal linkage still works (§3.5/3) and is no longer deprecated.

answered 2013-07-20T14:26:33.827

Your Answer