Annoying warnings using c++11/14

Hello,

When I use override in my classes I am harassed by warnings that come from rootcling. I think this is because the automatically generated code does not use override. I get tons of these warnings when running a simple script, which makes the nice warnings I should pay attention to useless as it gets lost in the noise.

Is this something that needs fixed in the rootcling dictionary generation?

Can this be turned off when running root? (eg root -Wno-inconsistent-missing-override myscript.cxx)

Here is a taste of the warnings:

/home/whit/projects/clasdigi/src/Hits/include/CLAS12HitsEvent.h:35:10: warning: 'ShowMembers' overrides a member function but is not marked 'override' [-Winconsistent-missing-overrid[50/521] ClassDef(CLAS12HitsEvent,5) ^ /opt/jlab_software/local/include/Rtypes.h:255:4: note: expanded from macro 'ClassDef' _ClassDef_(name,id,virtual,) \ ^ /opt/jlab_software/local/include/Rtypes.h:247:25: note: expanded from macro '_ClassDef_' virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \ ^ /opt/jlab_software/local/include/TObject.h:216:4: note: overridden virtual function is here ClassDef(TObject,1) //Basic ROOT object ^ /opt/jlab_software/local/include/Rtypes.h:255:4: note: expanded from macro 'ClassDef' _ClassDef_(name,id,virtual,) \ ^ /opt/jlab_software/local/include/Rtypes.h:247:25: note: expanded from macro '_ClassDef_' virtual_keyword void ShowMembers(TMemberInspector&insp) const overrd { ::ROOT::Class_ShowMembers(name::Class(), this, insp); } \ ^ In file included from input_line_12:13: /home/whit/projects/clasdigi/src/Hits/include/CLAS12HitsEvent.h:35:10: warning: 'Streamer' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] ClassDef(CLAS12HitsEvent,5) ^ /opt/jlab_software/local/include/Rtypes.h:255:4: note: expanded from macro 'ClassDef' _ClassDef_(name,id,virtual,) \ ^ /opt/jlab_software/local/include/Rtypes.h:248:25: note: expanded from macro '_ClassDef_' virtual_keyword void Streamer(TBuffer&) overrd; \ ^ /opt/jlab_software/local/include/TObject.h:216:4: note: overridden virtual function is here ClassDef(TObject,1) //Basic ROOT object ^ /opt/jlab_software/local/include/Rtypes.h:255:4: note: expanded from macro 'ClassDef' _ClassDef_(name,id,virtual,) \ ^ /opt/jlab_software/local/include/Rtypes.h:248:25: note: expanded from macro '_ClassDef_' virtual_keyword void Streamer(TBuffer&) overrd; \ ^ In file included from input_line_12:24: /home/whit/projects/clasdigi/src/Hits/include/ForwardHitMask.h:30:10: warning: 'IsA' overrides a member function but is not marked 'override' [-Winconsistent-missing-override] ClassDef(ForwardHitMask,1) ^ /opt/jlab_software/local/include/Rtypes.h:255:4: note: expanded from macro 'ClassDef' _ClassDef_(name,id,virtual,) \ ^ /opt/jlab_software/local/include/Rtypes.h:246:28: note: expanded from macro '_ClassDef_' virtual_keyword TClass *IsA() const overrd { return name::Class(); } \ ^ /opt/jlab_software/local/include/TObject.h:216:4: note: overridden virtual function is here

Cheers,
Whit

Hi Whit,

I would be interested in reproducing the issue: can you share one of your classes?
In general, the dictionary generator should inline in the generated code the information specified in the flags passed to it: did you try to pass "-Wno-inconsistent-missing-override " to rootcling when generating the dictionaries?

Cheers,
Danilo

Hi Whit,

When your class is using the override keyword, you need to replace the ClassDef macro with the macro ClassDefOverride.

Cheers,
Philippe.

1 Like

Just what I was looking for, thank you.

Thanks! This information should be mentioned in the User’s Guide https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#adding-a-class