-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround a fundamental ROOT issue with ClassDef and dictionaries.
ROOT needs reflection information about classes. One way to incorporate this information is to use a ClassDef macro, which adds a few members to the classes. For example, how to read/write the class on disk (aka streamer). The ClassDef adds forward declaration of a streamer function (and a few others) in the body of the class. Later on a special tool (aka rootcling) defines the forward declarations unless told otherwise by the dictionary generation driver (aka Linkdef file). Simply explained, the ROOT IO-aware class *declare* a few functions, whoose definitions will come from a dictionary. As always the interesting part comes when C++ templates come around. Depending on the order of the header files, which appear in the dictionaries the template class can be instantiated. For example: A.h: template<class T> struct TMyClassT { ...; ClassDef(MyClassT, 1); }; B.h: struct S { TMyClassT<int> var; }; G__: #include "A.h" // #1 #include "B.h" // #2 // Definitions of the contents of the ClassDef. B.h forces an implicit instantiation of TMyClassT *before* the compiler can see the definitions of the ClassDef. Namely, template <> TClass *TMyClassT<int>::Class(){} is seen after #2 when the compiler has instantiated it. C++ 14.7.3/6 explains it as: "If a template, a member template or a member of a class template is explicitly specialized then that specialization shall be declared before the first use of that specialization that would cause an implicit instantiation to take place, in every translation unit in which such a use occurs; no diagnostic is required." Saying that what we do makes the TU ill-formed but no diagnostic is required. Modules are more strict in that respect and issue diagnostics. This commit introduces a workaround while the actual solution to the problem is being developed. As Axel and I discussed a real solution would be to implement a ClassDef macro which inlines the contents, disallowing custom streamers covering 99.9% of the cases.
- Loading branch information
1 parent
e49515c
commit 5197ed6
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters