c++boost-bimap

Conflicting specifiers in declaration c++


I use a data structure bimap

typedef boost::bimap< std::string, int > hash_bimap;
typedef hash_bimap::value_type position;
hash_bimap perm;

and it works fine in main file. However, i am interested to use it in header file to make it accessible in any other .cpp file.

when I try to make it extern in my.h like

extern typedef boost::bimap< std::string, int > hash_bimap;
extern typedef hash_bimap::value_type position;
extern hash_bimap perm;

conflicting specifiers in declaration of ‘hash_bimap’ extern typedef boost::bimap< std::string, int > hash_bimap;


Solution

  • (elaborating on kfsone's comment) typedefs don't need to be extern, just the actual variable:

    typedef boost::bimap< std::string, int > hash_bimap;
    typedef hash_bimap::value_type position;
    extern hash_bimap perm;