I have two header files that I'm including from my main.cpp that have the following definition in an anonymous namespace: const string strToken = ("%");
Compiling using g++ version 4.9 results in this:
In file included from main.cpp:25:0:
libraries/trace.h:31:14: error: redefinition of ‘const string {anonymous}::strToken’
const string strToken = ("%");
^
In file included from libraries/debuglogger.h:12:0,
from libraries/packet.h:10,
from main.cpp:20:
libraries/strformat.h:23:14: note: ‘const string {anonymous}::strToken’ previously declared here
const string strToken = ("%");
^
I had thought that putting something in an anonymous namespace limited it to file scope, making this a non-issue. Am I missing something, or is this some sort of defect in GCC? If anyone wants the full code I would be willing to include it, but I'm hoping I've included enough information in my question to not need it.