Invoking an interpreted function from the compiled class

Dear ROOT developers,

I am trying to develop a pub/sub application that works with root. Once subscribed it waits for a message and start processing once a message is received. I have a C++ library which handles this scenario and I already wrote the necessary wrapper classes and got it loaded to the root interpreter. (CINT)

The compiled class requires a function pointer as the callback function to call when a message arrives. I was able to pass it and the program works(compiled code) till the point where it tries to call the function pointer.
There it fails with the following message

*** Segmentation Violation **

I even tried doing the same thing using a virtual method in a derived class and found that the virtual methods are not resolved correctly between the interpreted code and compiled code.

Could some one please help me to figure out the followings?

Is it possible to register callback functions between the interpreted code and the compiled code?
Does root support virtual functions in the latest releases?

Some help on how to do this will be really helpful.

Thanks in advanced.

Jaliya Ekanayake
jekanaya@cs.indiana.edu

I wanted to pass a function pointer from the interpreted code to the shared library that I developed as callback.

Hi,

to call an interpreted function from compiled code you can use CINT’s G__CallFunc interface - you cannot use plain C function pointers. If I understood your question then this is what you need. To call a compiled function from interpreted code you need a dictionary.

Virtual functions are of course supported in CINT. What you refer to (I believe) is the overload of a compiled function by an interpreted one, and the automatic call redirection from base (compiled) to derived (interpreted) function. This is not yet supported.

Cheers, Axel.

Hi Alex,

Thank you very much for the clarification!
Could you please point me to some document or a sample that shows how to use CINT’s G__CallFunc interface?

Thanks,
-jaliya

Hi,

see e.g. the different versions of ROOT’s TCint::Execute(), root.cern.ch/root/html/src/TCint.cxx.html#TVSoVD

Cheers, Axel.

Yes, I was able to get it working. :slight_smile:
Thank you very much Axel!
-jaliya