AddExec in a compiled code

Hi,

My apologies in advance if this has been discussed at length before.

I am trying to compile a code that has an ‘AddExec’ call in it. In fact , my routine is very very similar to this one where Rene solved the issue by changing the relevant function to a static one. [function is question: Trace::PeakPoint()].

My question is why must we make it a static function? Is there a way get around this. The reason I ask is what if I want to print out a object-member data (e.g. name of the histogram) depending on the mouse position. Of course, a static function does not allow me to access public class data.

What is even more surprising (to me) is that there are no such restrictions when you don’t compile the code and simply run it with CINT. What gives?

Sorry for the long-winded question.

Cheers
Erdos

Hi,

AddExec can only call static or global functions. This is because it does not look/select/use the object currently under the cursor. Instead the
static function should interrogate the gPad to know which object to use and hence call the proper non-static function.

[quote]What is even more surprising (to me) is that there are no such restrictions when you don’t compile the code and simply run it with CINT. What gives? [/quote]This is actually a bug (fixed in the SVN trunk) of CINT that use to allow any interpreted code to call a non-static function even when an object was not provided … leading to random result.

Cheers,
Philippe.