[ROOT] problem creating/using globals within root

From: jillings@caltech.edu
Date: Wed Nov 05 2003 - 19:51:47 MET


Hi all,
    I have a problem creating/using global objects. I have reproduced it
in sample code here.
 - I have two classes A & B.
 - in A.cc I define a global pointer gAptr
 - in B.cc I have a statement extern A* gAptr
 - B has a method which uses gAptr
 - I create the dict/.so file/... (see Makefile)
 - I compile executable code with an extern A* gAptr in the file     
abexe.cc ==> everything works
 - I load the .so file into root, instantiate gAptr, and I seg fault
   
I understand why this works in the compiled version - there is no
ambiguity about what gAptr is.

Running the same commands within root, it must be unclear about what
gAptr is and gAptr is just an automatically generated new variable, not
the global I'd defined.

Is there a way around this?
As a minor side question, what is the difference between R__EXTERN and
extern?

Thank you for your help,

Cheers,

Chris

--

********************************
Chris Jillings
Kellogg Radiation Laboratory
California Institute of Technology
jillings@caltech.edu
http://www.krl.caltech.edu/~jillings
********************************












This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET