Rootcint problem with non trivial class included

Dear all,

i would like to generate a dictionary for a class including unordered_map
class taken from gcc. This is a non trivial class with lot of pre-processor macros, templates, typedefs, … and since my experience with rootcint are the beginning i’m stuck with no idea to get it working.
Of course this file compile correctly so i guess it’s a problem connected to how i try to make the dict.

In attached tar file you can find MyClass.h, .C and files for unordered_map.
rootcint mydict.C -c MyClass.h gives lot of errors not so easy to understand …

Any comment will be highly appreciated :slight_smile:

Thanks and regards,
Max
test.tar (80 KB)

Hi,

[quote]i would like to generate a dictionary for a class including unordered_map [/quote]Do you want the dictionary for I/O or for being able to use the map from within an interpreted script?

Tryrootcint -f mydict.C -c -p MyClass.h which will get you past the issues CPP Macro.

Cheers,
Philippe.

Hi,

Since your class does not need the unordered map in its header, you can get your example to run simply by hiding the #include “unordered_map.h” either by surrounding it with #ifndef CINT:[/code]
#ifndef CINT
#include “unordered_map.h”
#endif[/code]or by telling rootcint to hide it rootcint -f dict.cxx -c -DEWCORE_UNORDERED_MAP_H MyClass.hor if you need some part of it, you can work around CINT’s difficulties with a file like// mymap.h #ifndef EWCORE_UNORDERED_MAP_H #define EWCORE_UNORDERED_MAP_H // Fake definition namespace ewpa_internal // tr1 sss { template<class Key, class T, class Hash = hash<Key>, class Pred = std::equal_to<Key>, class Alloc = std::allocator<std::pair<const Key, T> >, bool cache_hash_code = false> class unordered_map {}; } #endif // EWCORE_UNORDERED_MAP_H and userootcint -f dict.cxx -c mymap.h MyClass.h linkdef.h

Cheers,
Philippe.

Hi Philippe,

yes i don’t need to use the map in the class header for which i create i dictionary. However the real code it’s more complicated and i have this type
of include tree:

MyClass includes Foo includes unordered_map

and i don’t need to use Foo objects from MyClass when loading the dictionary
Doing the trick of using the mymap file i can overcome all the issues, but i’m still missing a dummy iterator for unordered_map, which is used in Foo and so appears as undefined for the compiler when creating so from dict file.
Can i add it to the mymap file ? i’ve looked in the unordered_map.h but it’s a bit difficult to identify where the iterator is defined …

thanks again,
cheers,
Max

Ok. Try with this file: #if defined(__CINT__) // mymap.h #ifndef EWCORE_UNORDERED_MAP_H #define EWCORE_UNORDERED_MAP_H // Fake definition namespace ewpa_internal // tr1 sss { template<class Key, class T, class Hash = hash<Key>, class Pred = std::equal_to<Key>, class Alloc = std::allocator<std::pair<const Key, T> >, bool cache_hash_code = false> class unordered_map {}; } #endif // EWCORE_UNORDERED_MAP_H
#endif CINT[/code]

Cheers,
Philippe.