When I try to compile an application that uses the Boost serialization library,
I get some compilation errors that I don't understand.
I've taken the code, and trimmed it down to the simplest possible case that
produces the same error.
Here's the code:
// Test of Boost serialization library
#include <sstream>
#include
class test_t {
public:
int i;
template <class Archive> void serialize(Archive& ar, const unsigned int
version ) { ar & i; }
test_t(int _i) : i(_i) {};
};
int main(void) {
std::ostringstream oss;
boost::archive::text_oarchive oa(oss);
test_t test(1);
oa << test;
return 0;
}
When I compile this (gcc 4.1.2, Boost 1.33.1, under Fedora 7), I get the
following error:
g++ serialization_test.cpp -l boost_serialization
/usr/include/boost/archive/detail/oserializer.hpp: In function ‘void
boost::archive::save(Archive&, T&) [with Archive =
boost::archive::text_oarchive, T = test_t]’:
/usr/include/boost/archive/basic_text_oarchive.hpp:78: instantiated from ‘void
boost::archive::basic_text_oarchive<Archive>::save_override(T&, int) [with T =
test_t, Archive = boost::archive::text_oarchive]’
/usr/include/boost/archive/detail/interface_oarchive.hpp:78: instantiated from
‘Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&)
[with T = test_t, Archive = boost::archive::text_oarchive]’
serialization_test.cpp:21: instantiated from here
/usr/include/boost/archive/detail/oserializer.hpp:567: error: invalid
application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’
Can someone explain to me WTF is going on? That error makes absolutely no sense
at all to me, and I'm at my wits end!
Thanks,
-- Dominick