Using STL map in compiled code

Hello all,
After trolling the forum for awhile, it seems that STL maps are giving lots of people problems. However none of the solutions I’ve found fix my problem. I’m running root 5.13 on debian 2.14
I have a simple class, MyClass, which has a vector of Double_t and a map of TString, Double_t pairs:

//File MyClass.hh
#ifndef MYCLASS_h
#define MYCLASS_h

#include "TObject.h"
#include "TString.h"
#include <vector>
#include <map>
#include <utility>

class MyClass : public TObject{
public:
  MyClass();
  ~MyClass();
  void AddaHit(Double_t energy, TString volume);
  void Zero();
  void Print();
  std::vector<Double_t> KE;
  std::map<TString,Double_t> vol;
  ClassDef(MyClass,1)
};

#endif

#ifdef __MAKECINT__
#pragma link C++ class TString+;
#pragma link C++ class std::vector<Double_t>+;
#pragma link C++ class std::pair<TString,Double_t>+;
#pragma link C++ class MyClass+;
#endif

The implementation MyClass.cc has the usual ClassImp(MyClass) macro. I generate the dictionary using “rootcint -f MyClassDict.cc -c MyClass.hh”, compile and link it into a main program which fills a tree with MyClass objects:

#include "MyClass.hh"
#include "TFile.h"
#include "TTree.h"

int main()
{
  TFile *f = new TFile("test.root","RECREATE");
  MyClass *mc = new MyClass;
  TTree *tree = new TTree("tree","tree");
  tree->Branch("myclass",&mc);
  
  mc->AddaHit(2.22,"veto");
  tree->Fill();
  
  mc->Zero();
  mc->AddaHit(1.65,"active");
  mc->AddaHit(2.41,"shield");
  mc->Print();
  tree->Fill();
  
  f->Write();
  f->Close();
  return 0;
}

It all compiles, but at run-time I get the message

[quote]Warning in TClass::TClass: no dictionary for class pair<TString,double> is available
[/quote].
When I go to look at the output file, the vector data are readable, but not the map data. Do I need to add some extra #pragma commands, or actually include map.h in my rootcint command?

Thanks!
Ben

rootcint -f MyClassDict.cc -c MyClass.hhThe default in this mode is to generate the dictionary on for MyClass (using the filename to guess) and ignore the embedded #pragma link.

Create a new file MyClassLinkdef.h which can either be empty or contain your pragma statements and do:ootcint -f MyClassDict.cc -c MyClass.hh MyClassLinkdef.h

Cheers,
Philippe.

It’s all magic to me, but it works! Thanks!