Robert Ramey wrote
The only reason to export a type is if one needs to
serialize it through a base class pointer. So, to me
the best way to suppress the warning would be
to not export the type.
The warning message appears even if you don't export
the type: Here is a simple test case
//==================================
#include
#include
#include
#include
#include
#include // no need to include
shared_ptr
#include
class Concrete {
public:
Concrete(const std::string& name ) : name_(name) {}
Concrete() {}
private:
std::string name_;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar,const unsigned int){
ar & name_;
}
};
class Base {
public:
Base(const std::string& name ) : name_(name) {}
Base() {}
virtual ~Base(){}
private:
std::string name_;
*std::vector vec_*;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int) {
ar & name_;
ar & vec_;
}
};
class Derived : public Base {
public:
Derived(const std::string& name ) : Base(name) {}
Derived() {}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int) {
ar & boost::serialization::base_object<Base>(*this);
}
};
BOOST_CLASS_EXPORT(Derived);
//==================================
Notice that I have not exported Concrete, but the
serialisation will spit out a warning message, about
class Concrete.
... boost_1_39_0/boost/serialization/extended_type_info_typeid.hpp", line
88:
warning #2414-D: delete of pointer to incomplete class
BOOST_STATIC_WARNING(boost::is_polymorphic<T>::value);
^detected during:
instantiation of "const boost::serialization::extended_type_info
*boost::serialization::extended_type_info_typeid<T>::get_derived_extended_type_info(const
T &) const [with T=Concrete]" at line 92 of
"/scratch/ma/emos/ma0/hpia64/boost/boost_1_39_0/boost/archive/shared_ptr_helper.hpp"
It looks like if we are serialising via a base ptr, and the
base class is serialising concrete data member via a shared ptr,
it has assumed that the type must be polymorphic. This does
not seem right to me ?
Best regards,
Ta,
Avi