[ROOT] pointer to function

From: Colin Bernet (bernet@hep.saclay.cea.fr)
Date: Thu Dec 12 2002 - 16:08:44 MET


Hello rooters, 

I've got a small problem with pointer to functions : 

file call.C :

#include <iostream>

int pass(int i) {
  return i;
}

int call(int (*func) (int)) {
  return func(10);
}


in interactive mode :

root [0] .L call.C++
Info in <TUnixSystem::ACLiC>: creating shared library
/.automount/dapservfic/root/home/usr202/mnt/bernet/p2f/./call_C.so
root [1] call(&pass)

 *** Break *** segmentation violation

When compiled this works, with or without a dictionnary.
Is this a known bug ? I'm using root 3.03/09, cint 5.15.56 on a redhat 6.2
I tried to find some information, but the only thing which sounds to be
related to this problem is :

http://root.cern.ch/root/Cint.phtml?extlib

"It is recommended to use typedef for pointer to function. Cint can
process basic pointer to function syntax, however, there can be bugs.
Typedef will prevent such bug"

what is meant by typedef ? I know what is a typedef but I don't
understand this sentence. 

Thanks,
Colin



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:23 MET