Genreflex - Warning: Unused class rule

Following up on my previous post (Generate LinkDef entries for class (or function) template instances), I am facing a problem with wildcarding class templates for dictionary generation.

In small example programs the use of genreflex correctly generates dictionaries, but when I try the same approach for a bigger project I get these:

Warning: Unused class rule: std::vector<MyNS::MyClass<*, *> >

with a selection file that contains:

<class pattern="MyNS::MyClass<*, *>" />

which is weird, because this exact same way works for small programs. Removing the wildcards and filling in actually instantiated templates will work in the bigger project, but then I am back to listing all the template instances…

Unfortunately the documentation on generating dictionaries with genreflex is limited. I just found, in the source code, that the warning implies that there was not no matching declaration of my pattern. Is there something I do wrong in my selection file?

I noticed that the selection file is sensitive to the order of the header files being thrown into genreflex and also whether I close my selection entries with ...>> or ...> >, so I think there is something trivial I’m missing, but I cannot figure out what…

Any way of debugging this?

Hi,

genreflex/rootcling (ultimately cling) can create template instantiations if the name of the specialisation is spelled entirely. Wildcards work only if the templates are instantiated in the headers exposed to the dictionary generator.

Cheers,
D

Hi Danilo,

Thanks for the explanation. Indeed I did not instantiate templates in de header files I was feeding into the genreflex executable… Even though this is a step forward in comparison to LinkDef in order to generate dictionary entries more transparently, it still requires me to list all of the used instances in a header file.

In my situation I would like the user of my API to make the instantiations, which doesn’t necessarily need to happen in header files… If only (during compile) I could retrieve the template instances and generate a complete selection xml file… Which doesn’t make much sense, because the dictionary is also needed at compile time…

Any thoughts on how I could make sure a dictionary could be generated with all the template instances used in the program? Or is this not possible? I was thinking; maybe before compiling I could do a static analysis of the header and implementation files to find instances that I want to persist and add them to the selection xml file, and then compile.

Hi,

what experiments usually do is to have an “umbrella header” which includes all the headers necessary to the dictionary generation and the the template instantiations to be selected with patterns.

Cheers,
D

Yes, that is what I also understood. However what if template instances are made by the user of my API? I cannot predict that the user will create an instance of MyClass<int, 42>, so this instance will be missing in the umbrella header. And when the user wants to do I/O with that instance, it wont work.

Or are you telling me that I will just need to have declared MyClass<int, 1> in the umbrella header and then use wildcarding in the selection xml file, in order for the user-defined instance to be picked up by ROOT?

Hi,

I am afraid that ROOT can serialise instances of classes or template instances for which the dictionary exists already.

Cheers,
D

Nor should you try :). In those cases, we expect the user to request the dictionary for all the classes and instance that are specific to his or her use cases.

Cheers,
Philippe.

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