Pointer to function

victor perevoztchikov (perev@mail.phy.ornl.gov)
Sat, 31 May 1997 12:43:46 -0400 (EDT)


Hello rooters,

I have a question about pointer to function.

Simple example.

#include <stdio.h>
int ff(int (*fptr)(const char *txt),const char *txt) {
(*fptr)(txt);
return 0;
}
int aaa(const char *txt){ printf(txt); return 0;}

root [0] .L ff.C
root [1] ff(aaa,"AAAA called\n");
AAAA called
root [2] ff(printf,"PPPP called\n");
PPPP called

Everything OK. Somehow CINT distinguishes pointer to
CINT function (aaa) from pointer to C++ function (printf)
and works well.

But when ff.C linked to ROOT, then
it still works with C++ function (printf) and does not
work anymore with CINT function. It is clear, that C++ does not understand
pointer to CINT function.

Questions:

1. Is it possible to call or execute CINT function from C++ code?
By pointer or by name or ...

2. Is it possible by value of pointer to understand does it pointed
out to C++ or to CINT function being inside C++ (not CINT) function?

Victor

-- 
-------------------------------------------------------------------------
Victor M. Perevoztchikov         perev@uther1.phy.ornl.gov  [ US
                                 perev@vxcern.cern.ch       [ CH
                                 perev@mx.ihep.su           [ RUS

Oak Ridge National Laboratory, MS 6374, Oak Ridge, TN 37831 (423-574 5928) Fax (423-576 5780) University of Tennessee, Knoxville, TN 37996-1200 (secre-at 423-974 3342) 9015 Ten Mile Rd. #209 Knoxville TN 37923 (423-693 2639)