Turn off linking with LinkDef.h in rootcint invocation

Hello, I have a class making use of some C++11 features in its internals. Specifically, I’m using unordered_map so my header contains:

#include "services/dataservice/DataWrapper.h"
#ifndef __CINT__
#include <unordered_map>
typedef std::unordered_map<std::string, VDataWrapper*> DataMap;
#endif

where VDataWrapper is a class I define in DataWrapper.h. In my class called DataService I then define a DataMap private member. Using this LinkDef.h:

#ifdef __MAKECINT__
#pragma link off all class;
#pragma link off all function;
#pragma link off all global;
#pragma link off all typedef;
#pragma link C++ class DataService;
#endif

I get this error when invoking rootcint:

Error: Symbol DataMap _map is not defined in current scope  /home/mori/analysis/Analyzer/include

OK, rootcint can’t see the definition of DataMap so it complains about it. Thus I tried to disable the linking of members of DataService adding to LinkDef.h:

#pragma link off all_datamember DataService;

but the error persist. It seems that, even if I tell rootcint to ignore the data members of DataService (including the DataMap type members), it still tries to handle them somehow, failing because the relevant definitions are included in a #ifndef CINT statement. Is this the intended behaviour or am I missing something important? Thanks.

Hi,

The failure appears when CINT ‘parses’ the class. The #pragma only tell rootcint to not write the dictionary for the class but does not affect what is parsed, only the #ifndef CINT does. You can usually work around this type of issues by using:#ifndef __CINT__ #include <unordered_map> typedef std::unordered_map<std::string, VDataWrapper*> DataMap; #else class DataMap; #endifIf this is not sufficient you will need to hide the data member itself from CINT (with the #ifndef)

Cheers,
Philippe.

Thanks Philippe, I’ve tried your suggestion and it works.