2012-02-15 14 views
1

私はブーストシリアル化を使用して新しいです。私はxmlのシリアル化と非侵入型を使用しています。私は(Boostのウェブサイトから)チュートリアルをステップバイステップで実行し、私のコードは正常に動作します。シリアライズとネームスペースをブースト

私は名前空間(ns_mytests)で私のクラスを(コードの.hと.cppのプラスmain.cppにファイルに分割された)入れたときに問題が発生します。この場合、コンパイラ(gは++)不平を言うと、私は次のエラーを持っている:

g++ -c -g test.o.d -o build/Debug/GNU-Linux-x86/sources/test.o sources/test.cpp 
/opt/local/include/boost/serialization/split_free.hpp: In static member function 'static void boost::serialization::free_saver<Archive, T>::invoke(Archive&, const T&, unsigned int) [with Archive = boost::archive::xml_oarchive, T = ns_mytests::Test]': 
/opt/local/include/boost/serialization/split_free.hpp:74: instantiated from 'void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_oarchive, T = ns_mytests::Test]' 
sources/test.h:117: instantiated from 'void boost::serialization::serialize(Archive&, ns_mytests::Test&, unsigned int) [with Archive = boost::archive::xml_oarchive]' 
/opt/local/include/boost/serialization/serialization.hpp:128: instantiated from 'void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_oarchive, T = ns_mytests::Test]' 
/opt/local/include/boost/archive/detail/oserializer.hpp:148: instantiated from 'void boost::archive::detail::oserializer<Archive, T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::xml_oarchive, T = ns_mytests::Test]' 
sources/test.cpp:146: instantiated from here 
/opt/local/include/boost/serialization/split_free.hpp:45: error: no matching function for call to 'save(boost::archive::xml_oarchive&, const ns_mytests::Test&, const boost::serialization::version_type&)' 
make[2]: *** [build/Debug/GNU-Linux-x86/sources/test.o] Error 1 
make[1]: *** [.build-conf] Error 2 
make: *** [.build-impl] Error 2 

それは私が何か間違ったことをやっていることは間違いないだろうが、私は私の誤りを見つけるcould't。

何か助けていただければ幸いです。

おかげで、 westfork

+1

これは、 'save(boost :: archive :: xml_oarchive、ns_mytests :: Test const&、boost :: serialization :: version_type const&)'というシグネチャを使って関数を呼び出そうとしているということです。機能?そうした場合、どの名前空間が_it_inですか? (_Hint_、_hint_、エラーだけでなくコードも表示してください) – ildjarn

+0

ありがとう。はい、それは名前空間に関する問題でした。 – westfork

答えて

1

直列化されるタイプが定義されている名前空間の非侵入saveを定義します。

+0

ありがとうございます。今すぐ使える – westfork

+0

あなたは大歓迎です。何か助けがあれば、答えを正しく記入してください。 –

関連する問題