Home | News | Documentation | Download

Including template functions in ROOT's CINT

To make available some useful function in CINT (C++ interpreter of ROOT), I configured my rootrc config file to execute a rootlogon.C file each time I run root to launch the interpreter.

In rootlogon.C, this piece of code is present:

  gROOT->ProcessLine("#include \"GenericToolbox.h\"");

This line is kind of working as intented since I’m then able to access most of the defined function in the header file. However the functions involving template can’t be accessed. I understand that because this is a header-only library, the interpreter can’t predict which object types will be used as template definition.

So do you know if I could make a kind of shared library that could be loaded in the rootlogon, which would define specific template functions?

I’ve seen some examples suggesting to utilize a LinkDef.h file which contains #pragma link C++ function lines to specialize templates, but I don’t understand how to use it…

Any idea?

ROOT version: 6.20/04

@pcanal can you give a hand?

Here is the included file:

Humm … Apriori this should work. What is the command line that fails and the error message?


PS. To reproduce the problem we will also need the file GenericToolbox.impl.h

My bad, this is actually working!

The only thing is when I type “tab” to list the availables functions, the template functions are not printed!
But when I try to call for a template function, it actually works.

Do you know if this auto-completion print issue is known and can be fixed?


It is (likely) the “intended” behavior. Tab can only list concrete classes/functions and already instantiated class/function template. I suppose we could enhance it a bit by also listing the generic part of the templates.

This certainly sounds like https://sft.its.cern.ch/jira/browse/ROOT-10141 - i.e. we’re aware of it!