Dear Rooters,
when using gROOT.LoadMacro from within a python script to use i.e. functions written in c++, I run into trouble as soon as the macro contains overloaded functions.
Here is a short example:
RootTestMacro.h:
#include <iostream>
void PrintAString(std::string myString){
std::cout<<myString<<endl;
}
void PrintAString(std::string myString1, std::string myString2){
std::cout<<myString1<<" "<<myString2<<endl;
}
which is called from
PythonTest.py:
import ROOT
ROOT.gROOT.LoadMacro('RootTestMacro.h+')
ROOT.PrintAString('Hello World')
ROOT.PrintAString('Hello World','once again')
which results as output in:
python PythonTest.py
Hello World
Traceback (most recent call last):
File “PythonTest.py”, line 6, in
ROOT.PrintAString(‘Hello World’,‘once again’)
TypeError: void ::PrintAString(string myString) =>
takes at most 1 arguments (2 given)
With this script only the first appearance of the overloaded function in the macro is accessible. Is there a way to access the overloaded implementations as well?
Regards,
Stefan