我试图在的Mac OS X中构建一个大项目,并遇到以下我无法解决的错误。构建错误:基本说明符必须命名一个类
Archive.hpp:92:30: error: base specifier must name a class
struct Derived : T, Fallback { };
代码:
template<typename T>
class has_save_func
{
struct Fallback { int save; }; // add member name "X"
struct Derived : T, Fallback { };
...
此外我有以下:
Archive.hpp:137:13: error: type 'unsigned long' cannot be used prior to '::'
代码:
template <class A>
static bool save(const A& data, class OutputArchive& oarchive, const std::string& id, typename boost::enable_if_c<has_save_func<A>::value, A>::type* def=NULL){
// todo check if A actually is friend with Access class, else return false
A::save(data, oarchive); // ! Error on this line !
return true;
}
template <class A>
static bool save(const A& data, class OutputArchive& oarchive, const std::string& id, typename boost::disable_if_c<has_save_func<A>::value, A>::type* def=NULL){
// todo check if A actually is friend with Access class, else return false
return serialization::save<A>(data, oarchive, id);
}
编码呼叫(OutputArchive.hpp):
template<class T>
void write(const T& data, const std::string& id){
// the data method must have an implementation of load/save and if not then we try the generic write
// method which could provide a solution by the implementation itself
writeEnterScope(id);
try {
Archive::Access::save<T>(data, *this, id);
} catch (...){
// we fall back to this call
boost::any adata(data);
write(adata, id);
}
writeLeaveScope(id);
}
代码serializeutil.cpp
void save(const rw::math::Q& tmp, OutputArchive& oar, const std::string& id){
oar.write(tmp.size(), "size");
for(int i=0;i<tmp.size();i++){
oar.write(tmp[i],"q");
}
}
难道是用编译器IM有问题吗?
是派生类模板吗? – juanchopanza
@juanchopanza,我无意中插入了错误的代码片段。这是纠正! – JavaCake
它看起来像你的模板参数'T'解析为一个整型。你怎么调用静态函数'save'? – juanchopanza