问题描述
我有以下代码在 MSVC14.13 (15.6) 中完美编译:
template <typename T>
struct Quat
{
#pragma warning( push )
#pragma warning( disable: 4201 ) // warning about non-std anonymous structs
union
{
struct { T x; T y; T z; T w; };
T arr[4];
};
#pragma warning( pop )
Quat() {}
Quat(T all) : x(all),y(all),z(all),w(all) {}
static inline const Quat<T> kZero = Quat<T>(static_cast<T>(0));
};
int main()
{
Quat<float> quat;
}
当我切换到 MSVC 14.16 (15.9) 时,出现以下错误:
consoleapplication18.cpp(18): error C2027: use of undefined type 'Quat<float>'
consoleapplication18.cpp(23): note: see declaration of 'Quat<float>'
consoleapplication18.cpp(23): note: see reference to class template instantiation 'Quat<float>' being compiled
如果我注释掉 kZero
行,它编译得很好。在 g++10 中也能很好地编译,所以我想知道这是否真的是编译器错误?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)