#include <iostream> namespace A { namespace { bool foo = false; } bool foo = true; void bar() { std::cout << foo << '\n'; } } int main() { A::bar(); }
Standard input is empty
prog.cpp: In function ‘void A::bar()’:
prog.cpp:14:22: error: reference to ‘foo’ is ambiguous
std::cout << foo << '\n';
^
prog.cpp:10:10: note: candidates are: bool A::foo
bool foo = true;
^
prog.cpp:7:14: note: bool A::{anonymous}::foo
bool foo = false;
^
prog.cpp: At global scope:
prog.cpp:7:14: warning: ‘A::{anonymous}::foo’ defined but not used [-Wunused-variable]
Standard output is empty