[ROOT] creation of gMyClassObject variable...

From: zaldy (zaldy@neutrino.kek.jp)
Date: Wed Jul 30 2003 - 13:23:54 MEST


Dear Fons and Valery,

Good Day...

How do we deal with the LinkDef.h file in a compile code?
Do we need to write it as a header-include-line
(i.e., #include "testLinkDef.h") in the class prototype/declaration?

In the manual, creation of this file is explained. But I would like to 
know how this file relates to the main file or Dictonary file or the class 
declaration file. Is it automatically detected during compilation?

My intention is to  create a global variable like gROOT. Then I will use 
this variable for the TButton functionality.

>From this file,
http://root.cern.ch/root/roottalk/roottalk98/0277.html

I created a test code and appended them here.
I used the command line:

  g++ -o myexe test.cc testDict.cc `root-config --cflags --glibs`
  
But error mesg is: gSB undeclared

What is wrong with this test code, and how do we correct it? 

Sorry for being slow here...
I would appreciate very much your reply.

Thank you.

-- 

--------------------------------------------------------
                   Zaldy A. Nawang 
                   PS Users Room 2
                   Yon Gokan, 
                   E362, Neutrino Group, 
                   IPNS, KEK, 
                   Japan 
                    
                   e-mail: zaldy@neutrino.kek.jp
                   Tel. No. : (81) 029864 - 5387
--------------------------------------------------------
//test.cc
^^^^^^^^^
#include <iostream>
#include "TROOT.h"
#include "TRint.h"
#include "TGlobal.h"


class test
{
  public:

   test();
   ~test();
   void greet();
   void shout();
};

//--------------------
//////////////////////
//////////////////////
//---critical---------

 test::test()
 {
  test ** p;
  TGlobal * g;
  gSB=this;  

  gROOT->Reset();
  {"test * gSB;"}

/****************************************************************
//  gROOT->ProcessLine("test * gSB");
//  gROOT->ProcessLine("#include \"testLinkDef.h\" ");
******************************************************************/

  g=gROOT->GetGlobal("gSB",kTRUE);
  p=(test **)g->GetAddress();
  *p=gSB;
  }

//---critical---------
//////////////////////
//////////////////////
//--------------------

  test::~test() 
 {;}
 
 void test::greet()
 {
  cout <<"Hello, how are you !!!"<<endl;
 }
  
 void test::shout()
 {
  cout<<"HHHHHHHHHHHHHHHHHHHHHHHHHHHH"<<endl;
  }


//----------------------------------------------------
int main(int argc, char **argv)
{
  
 TRint *theApp = new TRint("ROOT example", &argc, argv);

 test t;
 t.greet();

 theApp->Run(kTRUE);

 return 0;
}


//-------------------------------testLinkDef.h------------------------
#ifdef __CINT__
#pragma link C++ global gSB;
#endif


Dictionary
http://neutrino.kek.jp/~zaldy/root_work/MyRootFaq/testDict.cc



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