在提问之前,我阅读了之前的问题,但问题有所不同。我正在我的类中使用这个:
static constexpr char* kSuffix = "tos";
使用gcc和c++11编译时,我遇到了以下错误:
error: ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]
但是 constexpr
比 const
更加严格,所以一个 constexpr
必须是一个 const
,但反过来则不成立。所以我想知道为什么在这种情况下 gcc 没有识别出 constexpr
?