mardi 14 janvier 2020

C++ String literal and constants

Before asking this, I read previous question, but the issue is a bit different. I'm using this in my class:

static constexpr char* kSuffix = "tos";

Compiling with gcc with c++11 got me this error:

error: ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]

But constexpr is a stricter constraint than const does, so a constexpr is must a const, but not vice versa. So I wonder why is gcc not recognising constexpr in this case?

Aucun commentaire:

Enregistrer un commentaire