Problem with macro and stl map containing TString, TLine

Dear all,

I have a Macro that should use an stl map :

[code]#include
#include
#include “TLine.h”

gROOT->LoadMacro("./loader.C+");

map<TString, TLine> lines;
[/code]

And the loader is as this (taken from other posts on the forum) :

[code]#include
#include “TLine.h”

#ifdef MAKECINT
cout << “create dico” << endl;
#pragma link C++ class pair<TString,TLine>+;
#endif

[/code]

When using it in root ( .x script2.C ) , I get the following :

I-TUnixSystem::ACLiC: creating shared library /home/bvonhall/dev/modulesSVN/modules/amoreQA/AutoDict_allocator_pair_const_TString_TLine____cxx.so In file included from /home/bvonhall/dev/modulesSVN/modules/amoreQA/AutoDict_allocator_pair_const_TString_TLine____cxx_ACLiC_dict.cxx:16: /home/bvonhall/dev/modulesSVN/modules/amoreQA/AutoDict_allocator_pair_const_TString_TLine____cxx_ACLiC_dict.h:45: error: `TLine' was not declared in this scope /home/bvonhall/dev/modulesSVN/modules/amoreQA/AutoDict_allocator_pair_const_TString_TLine____cxx_ACLiC_dict.h:45: error: template argument 2 is invalid /home/bvonhall/dev/modulesSVN/modules/amoreQA/AutoDict_allocator_pair_const_TString_TLine____cxx_ACLiC_dict.h:45: error: template argument 1 is invalid /home/bvonhall/dev/modulesSVN/modules/amoreQA/AutoDict_allocator_pair_const_TString_TLine____cxx_ACLiC_dict.h:45: error: ISO C++ forbids declaration of `G__allocatorlEpairlEconstsPTStringcOTLinegRsPgR' with no type (...)

It must be something trivial, but I can’t find out what is the problem. It works if I replace TLine with TString or TObject.

Thanks in advance for your help.
Barth
script2.C (117 Bytes)
loader.C (155 Bytes)

Hi,

see attached scripts. Running .x script2.C works for me.

Cheers. Axel.
script2.C (181 Bytes)
loader.C (129 Bytes)

Thanks Axel,

My mistake was to to do

#pragma link C++ class pair<TString,TLine*>+; instead of #pragma link C++ class map<TString,TLine*>+;
(Note that “pair” was replaced by “map”)

Cheers

Hi,

not only - your files also had statements outside any function scope.

Cheers, Axel.