cereal icon indicating copy to clipboard operation
cereal copied to clipboard

About the use of CEREAL_CLASS_VERSION

Open yydy1983 opened this issue 1 year ago • 2 comments

There is no version in the data that has been serialized and saved. How can I read it in a program that has been upgraded with CEREAL_CLASS_VERSION?

yydy1983 avatar Jan 12 '24 04:01 yydy1983

If you had no version argument in your serialize functions, Cereal did not store any versioning info. So now you files are incompatible: Cereals tries to read versioning where there is none.

Data serialized without versioning cannot be loaded by a versioned serialization function (and vice versa). https://uscilab.github.io/cereal/serialization_functions.html

You could modify Cereal to store a version tag by default anyway or add some try catch afterwards... This would increase complexity and impact performance.

Cereal, by design, ignores versioning data management completely when you dont need it. If you suspect that you may need it later, you should add it from the start: at least the version argument so it will use the default version 0 for all classes.

dimateos avatar May 28 '24 11:05 dimateos