RE: [ROOT] static member in interactive session

From: Philippe Canal (pcanal@fnal.gov)
Date: Fri Oct 29 2004 - 00:53:22 MEST


Hi,

In the default build of CINT, the usage of static bool (and only of static bool) is explicitly disable.
On some machine, one can not take the address of a bool and hence CINT can not register properly the static variable.

This can be solved by comment out line 141 of cint/inc/G__ci.h as follow:

  /* For a machine which has unaddressable bool */
  #ifndef G__UNADDRESSABLEBOOL
  //#define G__UNADDRESSABLEBOOL
  #endif

We certainly need to review this setting.

Cheers,
Philippe.

-----Original Message-----
From: ribordy [mailto:Mathieu.Ribordy@umh.ac.be]
Sent: Thursday, October 28, 2004 2:37 PM
To: Philippe Canal
Cc: roottalk@cern.ch
Subject: RE: [ROOT] static member in interactive session


Philippe, below are the informations (please notice that it works fine 
with integer and fails with boolean),
thanks,
	Mathieu

g++ -O3 -Wall -fPIC -pthread -I$ROOTSYS/include -Iinclude -c -o src/Base.o src/Base.cc
rootcint -f src/BaseDictionary.cc -c  -Iinclude Base.hh
g++ -O3 -Wall -fPIC -pthread -I$ROOTSYS/include -Iinclude -c -o src/BaseDictionary.o src/BaseDictionary.cc
g++ -shared -O src/Base.o src/BaseDictionary.o -o  lib/libbase.so

and then in an interactive root session:
.L lib/libbase.so
Base a
a.PrintMsg("") // --> output: y = 1   , x = 1
a.x=0
a.y=0
a.PrintMsg("") // --> output: y = 1   , x = 0



include/Base.hh:

#ifndef __Base__
#define __Base__

#include <iostream>
#include "TString.h"

class Base {
 public:
  Base() {;}
  virtual ~Base() {;}
  static bool y;
  static int x;
  void PrintMsg(TString msg);

  ClassDef(Base,0)
};

#endif // __Base__


src/Base.cc:

#include "Base.hh"
using namespace std;

ClassImp(Base)

bool Base::y = true;
int Base::x = 1;

void Base::PrintMsg(TString msg) {
  cerr<<"y = "<<y<<"   , x = "<<x<<endl;
  cerr << msg << '\n';
};



On Thu, 28 Oct 2004, Philippe Canal wrote:

> Hi,
> 
> There is not information to know what's going on.  In particular is A::M
> inlined or not?
> Please send a example with enough information to reproduce the problem.
> 
> Cheers,
> Philippe. 
> 
> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]
> On Behalf Of ribordy
> Sent: Thursday, October 28, 2004 5:49 AM
> To: roottalk@cern.ch
> Subject: [ROOT] static member in interactive session
> 
> Hi rooters,
> I'm not sure what's wrong with that:
> I have a class A with a public bool static member f. I generate a dictionary
> and use it in an interactive session. There is a method M() printing the
> value of f.
> 
> In the interactive session, I simply do:
> 
> A a; a.M(); --> print f=true (that's how I initialized it) a.f=false; a.M();
> --> print f=true (shouldn't it be false ?)
> 
> of course, this problem disappears when f is not declared as a static
> member.
> 
> thanks,
> 	Mathieu
> 
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET