I'm porting some code from Swift to C++. I was doing the following at the top of every Swift file:
private let log = os.Logger("Foo")
This defines a log
variable that is local to the file. It's like static
in C and C++.
If I try a similar thing in C++, in an implementation file (not header):
static MyLib::Logger log("Foo");
I get this error:
Redefinition of 'log' as different kind of symbol, previous definition is here:
/.../usr/include/c++/v1/math.h:977:1: log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
So it conflicts with the mathematical log
function. Is there a way to keep my static log
variable and somehow give it priority to resolve the name conflict error? Or do I just need to rename my log variable?