Hi, I am having odd problems while trying to create an basic C++ array of objects from a precompiled class. Briefly, the interpreter crashes. I do this on: Linux persil 2.0.33 #7 Sat Apr 11 04:37:43 PDT 1998 i686 unknown with the egcs-g++ version of root. Here is how to reproduce the problem: create myclass.hh: #ifndef __myclass__ #define __myclass__ class myclass { public: myclass(); ~myclass(); void myprint() const; void SetX( const float & x ); void SetY( const float & y ); private: float fX; // x position in centimeters float fY; // y position in centimeters }; #endif create myclass.cc: #include <stdio.h> #include "myclass.hh" myclass::myclass() : fX(-1), fY(-1) {} myclass::~myclass() {} void myclass::SetX( const float & x ) { fX= x; } void myclass::SetY( const float & y ) { fY= y; } void myclass::myprint() const { printf("fX = %f, fY = %f\n",fX,fY); } rootcint myclass: persil:~/scratch> rootcint -f myclassCint.cc -c myclass.hh Note: operator new() masked 1c Note: operator delete() masked 1c Class myclass: Streamer() not declared Class myclass: ShowMembers() not declared compile: persil:~/scratch> g++ -fPIC -shared -o myclass.so myclassCint.cc myclass.cc -I${ROOTSYS}/include persil:~/scratch> create macro bugdemo.cc: { for( int i= 1; i<3; i++ ) { int ntrack= 3*i; myclass* varr= new myclass[ntrack]; for( int j=0; j<ntrack; j++ ) { varr[j]= myclass(); cout << "Pointer to varr[" << j << "]: " << &(varr[j]) << endl; } cout << endl; delete[] varr; } } Run root: persil:~/scratch> root ******************************************* * * * W E L C O M E to R O O T * * * * Version 2.00/07 20 May 1998 * * * * You are welcome to visit our Web site * * http://root.cern.ch * * * ******************************************* CINT/ROOT C/C++ Interpreter version 5.13.55, May 16 1998 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }. root [0] gSystem.Load("myclass.so"); root [1] #include <iostream.h> root [2] .x bugdemo.cc Pointer to varr[0]: 0x859044c Pointer to varr[1]: 0x8590454 Pointer to varr[2]: 0x859045c Pointer to varr[0]: 0x85990d0 *** Break *** segmentation violation *** Break *** keyboard interrupt Root > root [3] This is as far as I could simplify the problem I encountered in a much larger application. Any help is greatly appreciated. stefan ---Stefan Kluth---------------Lynen Fellow----------------|\--|\------- - LBNL, MS 50A 2160 - phone: +1 510 495 2376 - |/ |/ - - 1 Cyclotron Rd. - fax: +1 510 495 2957 - |\/\|\/\|' - ---Berkeley, CA94720, USA-----e-mail: SKluth@lbl.gov------|/\/|/\/|----
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:33 MET