Robert Ramey wrote:
Larry Smith wrote:
I can not get these struct members to
serialize; I get compile errors, e.g. this fails to compile:
ar & fld; // where fld is: char[200]
Hmmm - works for me. The following example compiles just fine.
#include <sstream>
#include
struct x {
char y[200];
template<class Archive>
void serialize(Archive & ar, const unsigned int version){
ar & y;
}
};
int main(int argc, char *argv[]){
std::stringstream os;
boost::archive::text_oarchive oa(os);
const x x1;
oa & x1;
}
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
The structs we have to deal with are 'C' structs, not
C++. They are included in approx 9000 source files;
90% of those source files are 'C', only 10% are C++.
All of the source is compiled with 'pack 1' ('/Zp1 on Windows,
__attribute__ ((packed)) on Linux gcc/g++) to eliminate
'pad fields' within the structs; all of the source files
depend on this packed layout, so it can not be changed - things
would break. Once we move to non-Intel servers, 'packed'
will no longer be used on the server side; this is another reason
to serialize-xfer-deserialize the data - the struct layouts/sizes
will be very different between the workstation and server.
Here's a highly reduced example:
-----------------------
/* cmdef.h */
/* NOTE: on Linux/Intel with gcc/g++ 'ADPACKED' is
* defined as '__attribute__ ((packed))'.
* on Windows the '/Zp1' compile option is
* used to pack the structs and 'ADPACKED'
* is defined as empty.
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ADPACKED NODE_MGR
{
char ApplName[8];
char CompName[8];
} NODE_MGR;
#ifdef __cplusplus
}
#endif
---------------------
/* arch.hpp */
#include