Hi, I’m trying to compile a dictionary generated by rootcint, and I’m running into some weird errors.
The sources I’m compiling are:
TestInfo.h
[code]namespace TestInfo
{
class TestClass;
std::vector Func(float num,int N);
class TestClass : public TObject
{
public:
TestClass(float i=0);
TestClass(const TestClass& in);
TestClass& operator=(const TestClass& in);
~TestClass() {}
const int& i() {return this->index;}
private:
int index;
ClassDef(TestClass,1);
};
};[/code]
TestInfo.cxx
[code]#include “TObject.h”
#include “TestInfo.h”
namespace TestInfo
{
ClassImp(TestClass)
TestClass::TestClass(float i)
{
this->index = i;
}
TestClass::TestClass(const TestClass& in)
{
this->index = in.index;
}
TestClass& TestClass::operator=(const TestClass& in)
{
this->index = in.index;
}
std::vector Func(float num,int N)
{
std::vector answer;
for(int i=0;i<N;i++)
{
answer.push_back(TestClass(num));
}
return answer;
}
};[/code]
And I have the following LinkDef
TestInfo_LikeDef.h
[code]#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclass;
#pragma link C++ nestedtypedef;
#pragma link C++ namespace TestInfo;
#pragma link C++ defined_in namespace TestInfo;
#pragma link C++ class TestInfo::TestClass+;
#endif[/code]
if you put them all in the same directory, I do the following:
which seems fine, and builds the files TestInfo_Dict.cxx and TestInfo_Dict.h.
I now try to compile these, with:
And I get the following load of errors:
In file included from TestInfo_Dict.h:34:0,
from TestInfo_Dict.cxx:17:
TestInfo.cxx:6:3: error: ‘TGenericClassInfo’ does not name a type
TestInfo.cxx:6:3: error: ‘GenerateInitInstance’ was not declared in this scope
TestInfo_Dict.cxx: In function ‘int G__TestInfo_Dict_107_0_1(G__value*, const char*, G__param*, int)’:
TestInfo_Dict.cxx:218:17: error: ‘TestClass’ was not declared in this scope
TestInfo_Dict.cxx:218:17: note: suggested alternative:
TestInfo.h:7:9: note: ‘TestInfo::TestClass’
TestInfo_Dict.cxx:218:26: error: template argument 1 is invalid
TestInfo_Dict.cxx:218:26: error: template argument 2 is invalid
TestInfo_Dict.cxx:218:33: error: invalid type in declaration before ‘;’ token
TestInfo_Dict.cxx:219:26: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
TestInfo_Dict.cxx:219:26: error: expected a type, got ‘TestClass’
TestInfo_Dict.cxx:219:26: error: template argument 2 is invalid
TestInfo_Dict.cxx:219:33: error: invalid type in declaration before ‘=’ token
TestInfo_Dict.cxx:219:111: error: cannot convert ‘std::vector<TestInfo::TestClass>’ to ‘int’ in initialization
TestInfo_Dict.cxx:220:37: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
TestInfo_Dict.cxx:220:37: error: expected a type, got ‘TestClass’
TestInfo_Dict.cxx:220:37: error: template argument 2 is invalid
TestInfo_Dict.cxx: In function ‘void G__setup_memfuncTestInfo()’:
TestInfo_Dict.cxx:525:73: error: ‘TestClass’ was not declared in this scope
TestInfo_Dict.cxx:525:73: note: suggested alternative:
TestInfo.h:7:9: note: ‘TestInfo::TestClass’
TestInfo_Dict.cxx:525:82: error: template argument 1 is invalid
TestInfo_Dict.cxx:525:82: error: template argument 2 is invalid
TestInfo_Dict.cxx:525:63: error: expected primary-expression before ‘(’ token
TestInfo_Dict.cxx:525:86: error: expected primary-expression before ‘)’ token
TestInfo_Dict.cxx:525:88: error: expected primary-expression before ‘float’
TestInfo_Dict.cxx:525:95: error: expected primary-expression before ‘int’
If I take out the ClassDef and ClassImp from TestInfo.cxx and TestInfo.h, and run g++ -I$ROOTSYS/include -c TestInfo.cxx -o TestInfo.o
, It compiles fine so my code is definitely legal C++, however I’d like to draw your attention to this set of errors in particular:
In file included from TestInfo_Dict.h:34:0,
from TestInfo_Dict.cxx:17:
TestInfo.cxx:6:3: error: ‘TGenericClassInfo’ does not name a type
TestInfo.cxx:6:3: error: ‘GenerateInitInstance’ was not declared in this scope
TestInfo_Dict.cxx: In function ‘int G__TestInfo_Dict_107_0_1(G__value*, const char*, G__param*, int)’:
TestInfo_Dict.cxx:218:17: error: ‘TestClass’ was not declared in this scope
TestInfo_Dict.cxx:218:17: note: suggested alternative:
Is there a header I’m forgetting to include for TGenericClassInfo?
And why doesn’t rootcint encose the function G__TestInfo_Dict_107_0_1 in my namespace like it’s supposed to? If it enclosed with the proper namespace, there wouldn’t be a problem.
I’m using root v5.34.00