Hello,
let’s say we define, e.g., following functions (myfun.C):
#include <iostream>
void myfun(const char * msg){
std::cout << " msg = " << msg << std::endl;
}
// Is it possible to call this function (callFunc) from python?
void callFunc(void (*msgFun)(const char*), const char* msg){
cout << " callFunc:" << endl;
(*msgFun)(msg);
}
void cppCall(){
// This works from C++
callFunc(&myfun,"cppCall");
}
and I would like to call the void callFunc(void (msgFun)(const char), const char* msg) function which takes pointer to a function argument (run.py), something like:
import ROOT
ROOT.gROOT.ProcessLine('.L myfun.C+g')
ROOT.myfun("msg") # this is ok
ROOT.cppCall() # this works too
ROOT.callFunc(ROOT.myfun,"msg2") # this doesn't work...
but this doesn’t work:
msg = msg
callFunc:
msg = cppCall
Traceback (most recent call last):
File "run.py", line 6, in <module>
ROOT.callFunc(ROOT.myfun,"msg2") # this doesn't work...
TypeError: void ::callFunc(void (*)(const char*) msgFun, const char* msg) =>
could not convert argument 1 (void/unknown arguments can't be set)
Is it possible to call the callFunc somehow from python?
Thank you in advance,
Jiri
myfun.C (361 Bytes)
run.py (206 Bytes)