For a short while now I've been using boost
serialization.
It works perfectly... except... it keeps coming up
one massive warning (that takes up ~100 lines). (see
below)
Whenever I get annoyed, I try to experiment and
then search for answers online, but no
luck.
I'm probably using the library incorrectly
somewhere.
So I made a small program that generates the
problem.
Any advice on what I could be doing wrong would be
appreciated.
I use vc++ 2008 btw.
Thanks.
Code:
--------------------------------------------
/* demonstration of problem.
The program asks the user for a number, and then
saves this
number to a file. When the user returns, the number is
remembered.
*/
#include <iostream>
#include
<fstream>
#include
<boost/serialization/shared_ptr.hpp>
#include
<boost/archive/text_oarchive.hpp>
#include
<boost/archive/text_iarchive.hpp>
// save and load methods
void save (const char *
fname);
bool load (const char * fname); // returns if successful
// I know this is way too simple to put in a class,
but bare with me
class Game
{
public:
Game () {
number = 0; }
void getNumberFromUser () {
std::cin >> number; }
int getNumber () { return
number; }
private:
int
number;
friend class
boost::serialization::access;
template<class
Archive> void serialize(Archive & ar, const unsigned int
version)
{
ar & number;
}
};
typedef boost::shared_ptr<
Game > Game_ptr;
Game_ptr game;
// entry
int main ()
{
game = Game_ptr( new Game );
// welcome
std::cout << "Hello\n";
// if file exists, recall the
number
if (load ("save.txt")) std::cout << "You're
number is " << game->getNumber() << ".\n";
// ask user for
number
std::cout << "Enter a number:
\n";
game->getNumberFromUser ();
// memorise
number
save ("save.txt");
// exit
return 0;
}
void save (const char * fname)
{
std::ofstream
ofs( fname );
boost::archive::text_oarchive oa( ofs
);
// save
oa <<
game;
}
bool load (const char * fname)
{
std::ifstream
ifs( fname );
if (!ifs) return false; // file doesn't
already exist
boost::archive::text_iarchive ia( ifs
);
// load
ia >> game; //
<------ Removing this line makes the warning go away
return true;
}
Warning:
--------------------------------------------
1>main.cpp
1>d:\dev\boostpro\boost\boost_1_40\boost\serialization\extended_type_info_typeid.hpp(88)
: warning C4099:
'boost::serialization::static_warning_impl<false>::STATIC_WARNING' : type
name first seen using 'struct' now seen using
'class'
1>
d:\dev\boostpro\boost\boost_1_40\boost\serialization\static_warning.hpp(115) :
see declaration of
'boost::serialization::static_warning_impl<false>::STATIC_WARNING'
1>
d:\dev\boostpro\boost\boost_1_40\boost\serialization\extended_type_info_typeid.hpp(85)
: while compiling class template member function 'const
boost::serialization::extended_type_info
*boost::serialization::extended_type_info_typeid<T>::get_derived_extended_type_info(const
T &) const'
1>
with
1>
[
1>
T=Game
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\shared_ptr_helper.hpp(105) : see
reference to class template instantiation
'boost::serialization::extended_type_info_typeid<T>' being
compiled
1>
with
1>
[
1>
T=Game
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\serialization\shared_ptr.hpp(138) : see
reference to function template instantiation 'void
boost::archive::detail::shared_ptr_helper::reset<Game>(boost::shared_ptr<T>
&,T *)' being compiled
1>
with
1>
[
1>
T=Game
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\serialization\split_free.hpp(58) : see
reference to function template instantiation 'void
boost::serialization::load<Archive,Game>(Archive
&,boost::shared_ptr<T> &,const unsigned int)' being
compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\serialization\split_free.hpp(54) : while
compiling class template member function 'void
boost::serialization::free_loader<Archive,T>::invoke(Archive &,T
&,const unsigned int)'
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=boost::shared_ptr<Game>
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\serialization\split_free.hpp(74) : see
reference to class template instantiation
'boost::serialization::free_loader<Archive,T>' being
compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=boost::shared_ptr<Game>
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\serialization\shared_ptr.hpp(153) : see
reference to function template instantiation 'void
boost::serialization::split_free<Archive,boost::shared_ptr<T>>(Archive
&,boost::shared_ptr<T> &,const unsigned int)' being
compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\serialization\serialization.hpp(133) :
see reference to function template instantiation 'void
boost::serialization::serialize<Archive,Game>(Archive
&,boost::shared_ptr<T> &,const unsigned int)' being
compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\iserializer.hpp(174) : see
reference to function template instantiation 'void
boost::serialization::serialize_adl<Archive,T>(Archive &,T &,const
unsigned int)' being compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\iserializer.hpp(161) :
while compiling class template member function 'void
boost::archive::detail::iserializer<Archive,T>::load_object_data(boost::archive::detail::basic_iarchive
&,void *,const unsigned int)
const'
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\iserializer.hpp(362) : see
reference to class template instantiation
'boost::archive::detail::iserializer<Archive,T>' being
compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\iserializer.hpp(351) :
while compiling class template member function 'void
boost::archive::detail::load_non_pointer_type<Archive,T>::load_standard::invoke(Archive
&,T &)'
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\iserializer.hpp(417) : see
reference to class template instantiation
'boost::archive::detail::load_non_pointer_type<Archive,T>::load_standard'
being compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\iserializer.hpp(405) :
while compiling class template member function 'void
boost::archive::detail::load_non_pointer_type<Archive,T>::invoke(Archive
&,T &)'
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\iserializer.hpp(542) : see
reference to class template instantiation
'boost::archive::detail::load_non_pointer_type<Archive,T>' being
compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\common_iarchive.hpp(61) :
see reference to function template instantiation 'void
boost::archive::load<Archive,T>(Archive &,T &)' being
compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\basic_text_iarchive.hpp(62) : see
reference to function template instantiation 'void
boost::archive::detail::common_iarchive<Archive>::load_override<T>(T
&,int)' being compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\text_iarchive.hpp(66) : see
reference to function template instantiation 'void
boost::archive::basic_text_iarchive<Archive>::load_override<T>(T
&,int)' being compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1>
d:\dev\boostpro\boost\boost_1_40\boost\archive\detail\interface_iarchive.hpp(61)
: see reference to function template instantiation 'void
boost::archive::text_iarchive_impl<Archive>::load_override<T>(T
&,int)' being compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1>
]
1> d:\dev\visual studio
2008\projects\boostserialisation\boostserialisation\main.cpp(82) : see reference
to function template instantiation 'Archive
&boost::archive::detail::interface_iarchive<Archive>::operator
>><Game_ptr>(T &)' being
compiled
1>
with
1>
[
1>
Archive=boost::archive::text_iarchive,
1>
T=Game_ptr
1> ]