ClassDef version when member changes

Hi all,

Sorry if this has been explained already or sounds like a newbie question. But I do have a question regarding ClassDef versioning which I have been asked a few times but never had a real answer and also could not find clear documentation. states

You will need to increase the version number whenever you change the definition of your class

but assuming I have

class A {
  // ...
  ClassDef(A, 1);

class B {
  // ...
  A a;
  ClassDef(B, 1);

class C: public A {
  // ...
  ClassDef(C, 1);

and I change the definition of A and increase the ClassDef version for A, do I also need to increment the versions for classes B and C? Technically I didn’t modify the definition of B or C but the memory layout might change.

Is there a clear answer?

ROOT Version: 6.14
Platform: Linux
Compiler: GCC 8.2

For the I/O, base classes are similar to special data members. As such, only changes of the immediate members count, not transitive changes. No need to increase the ClassDef version if members in bases change (your case C), or member in types of members (your case B). We take care of the rest!

(And note that the use of ClassDef is a performance optimization; ROOT can do I/O just fine without. The only exception is classes inheriting from TObject which generally require the use of ClassDef.)

I have updated the page - I hope it helps.

Hi Axel,

thank you, that helps indeed and now I can happily just point to the documentation.

Just one minor nitpick in the documentation: should the “or” I marked in bold be a “of”?

Only member changes (type, addition, removal, renaming) or immediate data members require incrementing of the class version.

Thanks for reporting the typo, fixed!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.