Cannot generate dictionary for STL map container

I am trying to generate a dictionary for the container std::map<unsigned int, unsigned int>. I have attached three files:

STLDictionary_Makefile (I had to upload it as STLDictionary_Makefile.txt because the forum didn’t like the _Makefile extension)

To generate the dictionary, I execute

mv STLDictionary_Makefile.txt STLDictionary_Makefile
make -f STLDictionary_Makefile

I am running on CERN LXPLUS, using CMSSWv5.2.4.patch3 and ROOT v5.32/00 (branches/v5-32-00-patches@42372). The CINT interpreter version is 5.18.00. When I execute make, I get the error

In file included from
STL_dict.h:54:9: error: ‘map’ does not name a type
make: *** [] Error 1

Can any of the experts reproduce this problem, or let me know what mistake I’m making?

Rachel Yohay
STLDictionary_LinkDef.h (203 Bytes)
STLDictionary_Makefile.txt (2.78 KB) (32 Bytes)

STLDictionary.hh (15 Bytes)
STLDictionary_LinkDef.h (273 Bytes)
STLDictionary_Makefile.txt (2.8 KB)

Thank you for the code modification. It fixed the problem.

Now I’m trying to generate an STL dictionary for a more complicated object, map<string, pair<string, string> >. The dictionary is generated okay (the code doesn’t crash). However, I run into trouble when I try to use these objects in a ROOT macro. Attached are two files:


To build the dictionary, I use the exact version of STLDictionary.hh and STLDictionary_Makefile that you gave me, and execute

make -f STLDictionary_Makefile

This runs without error. However, when I try to run the attached ROOT macro with

root -l -b -q formatPlots.C

I get the error

Processing formatPlots.C…
Error: can not call private or protected function formatPlots.C:21: -1 pair<string,string>& pair<string,string>::operator=(const pair<string,string>&);
Calling : pair<string,string>::operator=(pair<string,string>);
Match rank: file line signature

  •    1  -1 pair<string,string>& pair<string,string>::operator=(const pair<string,string>&);

*** Interpreter error recovered ***

Any idea what’s causing that error? It seems that the operator= of pair<string, string> is being built as private or protected when it needs to be public in order to use it to fill the map.

formatPlots.C (495 Bytes)
STLDictionary_LinkDef.h (250 Bytes)

Nevermind, I figured out the problem. The solution was to add the line

#pragma link C++ function pair<string, string>::operator=(const pair<string, string>&);

to STLDictionary_LinkDef.h and rerun make -f STLDictionary_Makefile. Thanks again for all your help.

  • Rachel


You can also try#pragma link C++ operator myclass;