Hi,
I have a code that work when compiled but not when interpreted,
here is the relevant part:
in test.C:
void test(TH2D** &h,int n){
h=new (TH2D*)[n];
for (int i=0;i<n;i++){
char name[10];
sprintf(name,"h%d",i);
h[i] = new TH2D(name,"bla",128,0,128,128,0,128);
}
}
isdcpc3:~/investigate 102> root
*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 3.04/02 5 March 2003 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************
Compiled for linux with thread support.
CINT/ROOT C/C++ Interpreter version 5.15.68, Dec 12 2002
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L test.C
root [1] TH2D** pifs;
root [2] test(pifs,3);
Error: Symbol TH2D is not defined in current scope FILE:test.C LINE:2
Syntax Error: TH2D* FILE:test.C LINE:2
Error: memory allocation for (TH2D*) size=4 pinc=3
FILE:/home/isdc/produit/investigate/./test.C LINE:2
Warning: Automatic variable h allocated in global scope FILE:test.C LINE:2
Error: Undeclared variable h FILE:test.C LINE:2
*** Interpreter error recovered ***
root [3]
Then I try:
in test.C:
void test(TH2D** &h,int n){
h=new TH2D*[n];
for (int i=0;i<n;i++){
char name[10];
sprintf(name,"h%d",i);
h[i] = new TH2D(name,"bla",128,0,128,128,0,128);
}
}
isdcpc3:~/investigate 103> root
*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 3.04/02 5 March 2003 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************
Compiled for linux with thread support.
CINT/ROOT C/C++ Interpreter version 5.15.68, Dec 12 2002
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L test.C
root [1] TH2D** pifs;
root [2] test(pifs,3);
Error: Symbol i is not defined in current scope FILE:test.C LINE:3
*** Break *** segmentation violation
Generating stack trace...
*** Break *** keyboard interrupt FILE:test.C LINE:3
*** Break *** keyboard interrupt
Root >
an then I have to kill the terminal...
--
Nicolas Produit
INTEGRAL Science Data Center Phone: +41 22 950 91 40
16, Chemin d'Ecogia Fax: +41 22 950 91 33
CH-1290 Versoix www: http://isdc.unige.ch/
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET