Problem with dictionary creation; templates and std::set

Dear ROOT-team,

I’ve got a problem with the creation of the dictionary.

I’ve reduced the code to a small example:

#include <set>

namespace AAA {
   class ISoul {
   public:
      ISoul(){}

      ClassDef(ISoul,0)
   };

   namespace BBB {
      template<typename T> class IConst : public AAA::ISoul {
      public:
	 IConst() {}
	 virtual IConst* Create( IConst* /*parent*/, T /*value*/ ) { return NULL; }
	 virtual void    Set( T /*value*/ ) {}
	 ClassDef(IConst,0)
      };


      template<typename T> class Const;
      

      template<typename T> class Value : public AAA::BBB::IConst<T> {
      public:
         Value( Const<T>* cnst ) : AAA::BBB::IConst<T>() { fConst = cnst; }
	 virtual IConst<T>* Create( IConst<T>* parent, T value ) {
	    if( parent == NULL )
	       return fConst->Create(this,value);
	    return fConst->Create(parent,value);
	 }
	 virtual void    Set( T value ) { fValue = value; }
	 
      protected:
	 Const<T>* fConst;
	 T fValue;

	 ClassDef(Value,0)
      };


      template<typename T> class Const : public AAA::BBB::IConst<T> {

	 typedef std::set< AAA::BBB::IConst<T> * > ConstSet;
	 typedef typename ConstSet::iterator ConstSetIterator;

      public:
	 Const() : AAA::BBB::IConst<T>()  {}
	 virtual IConst<T>* Create( IConst<T>* parent, T value ) {
	    ConstSetIterator it  = fConstValues.find( parent );
	    if( it != fConstValues.end() ){
	       return (*it);
	    }
	    IConst<T>* cnst = new Value<T>(this);
	    cnst->Set( value );
	    fConstValues.insert( cnst );
	    return cnst;
	 }
	 
      protected:
	 ConstSet fConstValues;

	 ClassDef(Const,0)
      };



   }
}


int main(){
   AAA::BBB::Const<Float_t>* cnst = new AAA::BBB::Const<Float_t>();
   AAA::ISoul* s = cnst->Create(NULL,33.3);

}

My LinkDef.h looks like that:

#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link off all namespaces;

#pragma link C++ nestedclass;

#pragma link C++ namespace AAA;
#pragma link C++ namespace AAA::BBB;

#pragma link C++ class AAA::BBB::ISoul+;
#pragma link C++ class AAA::BBB::IConst<Float_t>+;
#pragma link C++ class AAA::BBB::Const<Float_t>+;
#pragma link C++ class AAA::BBB::Value<Float_t>+;
#pragma link C++ class std::set< AAA::BBB::IConst<Float_t> * >+;

#endif

When making, I get the following errors:

Compiling dictionary AAA_Dict.C
In file included from AAA_Dict.h:33,
                 from AAA_Dict.C:16:
RootProblemTester.h: In function »int main()«:
RootProblemTester.h:74: Warnung: Variable »s« wird nicht verwendet
AAA_Dict.C: At global scope:
AAA_Dict.C:58: Fehler: »IConst« ist kein Element von »ROOT::Shadow::AAA::BBB«
AAA_Dict.C:58: Fehler: »IConst« ist kein Element von »ROOT::Shadow::AAA::BBB«
AAA_Dict.C:58: Fehler: Templateargument 1 ist ungültig
AAA_Dict.C:58: Fehler: Templateargument 2 ist ungültig
AAA_Dict.C:58: Fehler: Templateargument 3 ist ungültig
AAA_Dict.C:58: Fehler: expected unqualified-id before »,« token
AAA_Dict.C:58: Fehler: »IConst« ist kein Element von »ROOT::Shadow::AAA::BBB«
AAA_Dict.C:58: Fehler: »IConst« ist kein Element von »ROOT::Shadow::AAA::BBB«
AAA_Dict.C:58: Fehler: Templateargument 1 ist ungültig
AAA_Dict.C:59: Fehler: »IConst« ist kein Element von »ROOT::Shadow::AAA::BBB«
AAA_Dict.C:59: Fehler: »IConst« ist kein Element von »ROOT::Shadow::AAA::BBB«
AAA_Dict.C:59: Fehler: Templateargument 1 ist ungültig
AAA_Dict.C:59: Fehler: Templateargument 2 ist ungültig
AAA_Dict.C:59: Fehler: Templateargument 3 ist ungültig
AAA_Dict.C:59: Fehler: expected unqualified-id before »,« token
AAA_Dict.C:59: Fehler: »IConst« ist kein Element von »ROOT::Shadow::AAA::BBB«
AAA_Dict.C:59: Fehler: »IConst« ist kein Element von »ROOT::Shadow::AAA::BBB«
AAA_Dict.C:59: Fehler: Templateargument 1 ist ungültig
AAA_Dict.C:62: Fehler: »ConstSet« bezeichnet keinen Typ
AAA_Dict.C: In function »void ROOT::AAAcLcLBBBcLcLConstlEfloatgR_ShowMembers(void*, TMemberInspector&, char*)«:
AAA_Dict.C:580: Fehler: »class ROOT::Shadow::AAA::BBB::ConstlEfloatgR« hat kein Element namens »fConstValues«
AAA_Dict.C:581: Fehler: »class ROOT::Shadow::AAA::BBB::ConstlEfloatgR« hat kein Element namens »fConstValues«
make: *** [obj/AAA_Dict.o] Fehler 1

I tried to compile with ACliC, but I get similar errors there as well.

I attached the example, the LinkDef and the Makefiles i use (remove the extension .txt).

How do I get the dictionary created?

thanks,
Peter
Makefile.arch.txt (14.2 KB)
Makefile.txt (5.04 KB)
LinkDef.h (510 Bytes)
RootProblemTester.h (1.6 KB)

Hi,

I can not reproduce the problem. Which version of ROOT are you using? Can you try with v5.25/02 ?

Cheers,
Philippe.

I tried on two different computers with ROOT 5.23.01 and now with ROOT 5.25.02 (from AFS) and I run every time into the same problem.

I tried as well with 5.25.02 both, compiling with make and compiling with Aclic. Same result everywhere. I get the same problem as well if I don’t compile, but only load the file in CINT and then try to run main().

cheers,
Peter

Hi,

Note that rootcint does not work if it sees a header file with a main function so you need to use:[code]#ifndef CINT
int main(){
AAA::BBB::Const<Float_t>* cnst = new AAA::BBB::Const<Float_t>();
AAA::ISoul* s = cnst->Create(NULL,33.3);

}
#endif[/code]

You also have a bug in your linkdef where you need to replace[code]diff LinkDef.h goodLinkDef.h
13c13
< #pragma link C++ class AAA::BBB::ISoul+;

#pragma link C++ class AAA::ISoul+;
[/code]

Cheers,
Philippe.