namespace { int Foo (int a); }
Is this code snippet legal? If so, can I reference Foo in anywhere, or only in a certain domain?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is legal, You can use
Fooanywhere in the same Translation Unit.Anonymous namespace is the standard prescribed way of saying
staticon variables to limit their scope to the same Translation unit.C++03 Standard section 7.3.1.1 Unnamed namespaces
para 2:
Update:
As @Matthieu M. correctly points out in the comments, and his answer The C++11 Standard removed the above quote from C++03 Standard, which implies that the
statickeyword is not deprecated when declaring objects in a namespace scope, Anonymous or Unnamed namespaces are still valid nevertheless.