How to access to anonymous namespace variable if the same variable exists in global
问题 Let's imagine situation: #include <iostream> int d =34; namespace { int d =45; } int main() { std::cout << ::d ; return 0; } Here the output is 34, because :: means global namespace. But If I comment 3rd line the output is 45, which is strange . If I use std::cout << d ; - I get error s.cxx:12:15: error: reference to ‘d’ is ambiguous How can I access unnamed_namespace::d in this scenario? PS: I've read that unnamed namespace is used for static global variables aka visible only in file scope