Consider the following class in which I define 2 static variables with constant value and initialisation upon declaration.
Both variable are primitive, but for the string initialisation I get the following error when compiling with LLVM (clang) Non-const static data member must be initialized out of line
even though its type is preceded by const
. In visual studio, the same code passed compilation.
perhaps anybody can explain this discrepancy ?
class my class
{
public:
// the variable in this line is recognised as non-const.
// Therefore, it doesn't allow initialisation.
static const wchar_t* bla = L"000111";
// this line compiles perfectly well.
static const int bla2 = 128;
}