Linker error (undefined reference) with `static constexpr const char*` and perfect-forwarding [duplicate]
问题 This question already has answers here : Undefined reference to static constexpr char[] (6 answers) Closed 4 years ago . #include <iostream> using namespace std; template<typename T> void print(T&& mX) { std::cout << std::forward<T>(mX) << std::endl; } struct SomeStruct { static constexpr const char* someString{"hello!"}; SomeStruct() { print(someString); } }; int main() { SomeStruct s{}; return 0; } clang++ -std=c++1y ./code.cpp -o code.o /tmp/code-a049fe.o: In function `SomeStruct: