使用clang编译时出错:在类定义结束之前,异常规范不可用 在MaCOS.c/p>编译C++.38的C++库时出错 template<class T> struct _reference_base<T, int> { enum { rb_tag = 1 }; typedef T t; static inline t* deref(_stg_u& x, bool byptr) throw() { return reinterpret_cast<t*>(byptr ? x.p1 : &x); } static inline t* _drf_c(const unity* p) throw() { return deref(p->_data, p->isByPtr()); } }; template struct\u reference\u base { 枚举{rb_tag=1};类型定义T; 静态内联t*deref(_stg_&x,bool byptr)throw(){return reinterpret_cast(byptr?x.p1:&x);} 静态内联t*_drf_c(const unity*p)throw(){return deref(p->_data,p->isByPtr());} };

使用clang编译时出错:在类定义结束之前,异常规范不可用 在MaCOS.c/p>编译C++.38的C++库时出错 template<class T> struct _reference_base<T, int> { enum { rb_tag = 1 }; typedef T t; static inline t* deref(_stg_u& x, bool byptr) throw() { return reinterpret_cast<t*>(byptr ? x.p1 : &x); } static inline t* _drf_c(const unity* p) throw() { return deref(p->_data, p->isByPtr()); } }; template struct\u reference\u base { 枚举{rb_tag=1};类型定义T; 静态内联t*deref(_stg_&x,bool byptr)throw(){return reinterpret_cast(byptr?x.p1:&x);} 静态内联t*_drf_c(const unity*p)throw(){return deref(p->_data,p->isByPtr());} };,c++,clang,C++,Clang,在这一行:static inline t*_drf_c(const unity*p)throw(){return deref(p->_data,p->isByPtr());} 这一行: 静态内联t*deref(_stg_&x,bool byptr)throw(){return reinterpret_cast(byptr?x.p1:&x);}我找到了解决方案。这个库是用c++11编写的,所以我需要激活c++11。我添加了cmake行 set(CMAKE\u CXX\u STANDARD 11)这

在这一行:
static inline t*_drf_c(const unity*p)throw(){return deref(p->_data,p->isByPtr());}

这一行:
静态内联t*deref(_stg_&x,bool byptr)throw(){return reinterpret_cast(byptr?x.p1:&x);}
我找到了解决方案。这个库是用c++11编写的,所以我需要激活c++11。我添加了cmake行


set(CMAKE\u CXX\u STANDARD 11)

这是一个仅针对CMAKE的解决方案,它没有说明导致错误的直接原因。实际上没有。这意味着,它没有编译,因为c++11未启用,这就是重点。