lundi 16 septembre 2019

Where to declare BOOST_CLASS_EXPORT for serialization

I want to serialize my data and i have polymorphic classes .

Initially when i was learning the process of the Serialization i declared the Inherited class in their header files.

  Header file for Sphere which is sub class of geometry
  BOOST_CLASS_EXPORT(Sphere)

but when i tried doing in my project i got the linker error2005 stating that the object is already defined in the object.

So i tried declaring the BOOST_CLASS_EXPORT(Sphere) in the cpp file but than i got error message derived class not registered or exported.

Eventually i got it working by declaring the derived class in the Main file.

  BOOST_CLASS_EXPORT_GUID(Sph, "Sph"); 

But the problem here is that if i have 30 objects i will need to declare them in the main file and if i add any new classes than again i need to declare them in main file.

Can i define the export in their header or cpp files of the class.

Aucun commentaire:

Enregistrer un commentaire