Class in namespace inheriting from templated class problem

Hi guys,

Using 5.32/00 here.

I have a class in a namespace that I’m having trouble processing with rootcint. The class is defined as follows:


namespace DmtpcMath
{
  class Rational
   : public ROOT::Math::ParamFunction<ROOT::Math::IParamGradFunction> ,
     public ROOT::Math::IGradientOneDim
  { 
    ...
   ClassDef(Rational,1); 
  };
}

I have a ClassImp in the source file, and I have a Linkdef file with

  #pragma link C++ namespace DmtpcMath; 
  #pragma link C++ class DmtpcMath::Rational+;

(I have a similar problem with both + and not + on the class in the Linkdef, so that’s not the issue).

When I attempt to compile the file generated by rootcint, I get the following error:

DmtpcMathCint.cc: In member function ‘virtual void DmtpcMath::Rational::ShowMembers(TMemberInspector&)’:
DmtpcMathCint.cc:162: error: ‘DmtpcMath::ROOT::Math’ has not been declared
DmtpcMathCint.cc:162: error: expected primary-expression before ‘:’ token
DmtpcMathCint.cc:162: error: expected `]' before ‘:’ token
DmtpcMathCint.cc:162: error: expected `)' before ‘:’ token

Line 162 in DmtpcMatchCint.cc is:

R__insp.GenericShowMembers("ROOT::Math::ParamFunction<ROOT::Math::IParametricGradFunctionOneDim>", ( ::ROOT::Math::ParamFunction<ROOT::Math::IParametricGradFunctionOneDim> *) (this ), false);

I can get it to compile and work properly if I modify the rootcint output to the following: (note the :: in the template)

R__insp.GenericShowMembers("ROOT::Math::ParamFunction<ROOT::Math::IParametricGradFunctionOneDim>", ( ::ROOT::Math::ParamFunction< ::ROOT::Math::IParametricGradFunctionOneDim> *) (this ), false);

Suggesting that rootcint was generating improper code (although I don’t understand why it was picking the wrong namespace inside the template…). The problem happens even if I prefix the ROOT namespace with :: everywhere in my header file. Is there some way to work around this issue?

-Cosmin

Hi,

Using:namespace DmtpcMath { class Rational #ifndef __CINT__ : public ROOT::Math::ParamFunction<ROOT::Math::IParamGradFunction> , public ROOT::Math::IGradientOneDim #endif { ... ClassDef(Rational,1); }; }

should work around the problem (assuming you don’t need to store the content/values of the base classes into a ROOT file).

Cheers,
Philippe.

While the workaround would work if I didn’t need to persist, (and I can use a postprocessor in my Makefile to “fix” the problem) it seems like this issue shouldn’t be too hard to fix in rootcint… is it fixed in a newer version?

[quote] is it fixed in a newer version?[/quote]This should be fixed when we migrate to using cling for ROOT 6 :slight_smile:

Cheers,
Philippe.