C++ global variable not initialized when linked through static libraries, but OK when compiled with source
问题 I have created a system that automatically registers function objects (functors) into a map based on the constructor of an global instance. In each cpp file that defines the functor, there's a global instance of the registrar class instance to register the functor to a singleton std::map<int, std::function<...> > object. This is the definition of registrar class: template < typename map_type, typename handler_type > struct registrar { registrar ( map_type& map_object, boost::uint16_t cmd_code