Robert Ramey wrote:
#include
#include #include "cmdef.h"
namespace boost { namespace serialization {
template<class Archive> void serialize(Archive & ar, struct NODE_MGR & st, const unsigned int version) { ar & st.ApplName; // line 19 in err msg ar & st.CompName; // line 20 in err msg }
} // end namespace serialization */ } // end of namespace boost */
--------------------
/* arch.cpp */
#include <sstream>
#include "arch.hpp"
int main() { const struct NODE_MGR nm; // this will fix errors in second case - see rationale std::ostringstream ofs; boost::archive::text_oarchive oa(ofs);
oa << nm; // line 15 in err msg
return 0; }
Compiling arch.cpp produces these errors:
arch.hpp:19: error: cannot bind packed field ‘st->NODE_MGR::ApplName’ to ‘char (&)[8]
arch.hpp:20: error: cannot bind packed field ‘st->NODE_MGR::CompName’ to ‘char (&)[8]
However, on the workstation side the structs MUST remain 'packed'; otherwise thousands of source files will have to be modified.
Is there any way to make this work with boost archives, or should I explore other options?
I don't see how this could be addressed from within the serialization library. It looks like anthing that looks like
ostream os; os << nm;
is going to fail as well. I suspect that your strategy is going to be foiled whether you use the serialization or some other method.
Robert Ramey
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Ok, I see how 'const struct NODE_MGR nm' fixes part of the problem... I don't understand why the lib should care about the data alignment of the struct's (packed versus unpacked). If I remove 'packed' from the struct's it builds & works OK; with 'packed' it won't compile. On the server side (the receiver) 'packed' won't be used, but on the workstation side (the sender) 'packed' must be used to keep from breaking 100+ existing workstation apps. Thanks for the help. Larry