error code is C2131.
intelisense does not complain even when I call size of on this variable in other files intelisense knows the size. what am I missing to get this working? Any help is greatly appreciated. In the pic below see intelisense not complaining and also determining size.
example a.h:
class a
{
private:
static constexpr char m_pszFoo[] = "***FOO***"; // compile error on this line C2131 expression did not evaluate to a constant
public:
a() { sizeof(m_pszFoo); }; // no compile error here
};
to reproduce all you need to do is include a.h in any other file. It won't reproduce without the include.
So I came up with a work around b\c that error message made it seem like i needed to add a const somewhere
static constexpr char const m_pszFoo[] = "**FOO***";
for some reason if we tell the compiler that we should not be able to change the char to which the string points msvc is happy.
* Edit *
I got some suggestions to file a bug with microsoft and let them investigate as this looks to be an interop bug with msvc. here is the connect.microsoft link: https://connect.microsoft.com/VisualStudio/feedback/details/2781048
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With