c++boostboost-mpl

Boost 1.61 header is trying to redefine mpl_::bool_


I'm on Boost 1.61 and compiling with clang 4.0.1 and I'm compiling for linux-gnu

Previously I was on Boost 1.52 and was not having this issue. Just by changing versions, I'm getting a compiler error about redefining mpl_::bool_

I'm not using any precompiled boost libs. This is headers only.

This is my include and the only include of boost:

#include <system/math/math.h>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>

I'm getting a compiler error:

1>  In file included from myfile.cpp:9:
1>  In file included from boost_1_61_0\boost/interprocess/managed_shared_memory.hpp:25:
1>  In file included from boost_1_61_0\boost/interprocess/detail/managed_memory_impl.hpp:30:
1>  In file included from boost_1_61_0\boost/interprocess/segment_manager.hpp:38:
1>  In file included from boost_1_61_0\boost/interprocess/allocators/allocator.hpp:30:
1>  In file included from boost_1_61_0\boost/interprocess/allocators/detail/allocator_common.hpp:32:
1>  In file included from boost_1_61_0\boost/interprocess/sync/scoped_lock.hpp:35:
1>  In file included from boost_1_61_0\boost/interprocess/detail/posix_time_types_wrk.hpp:32:
1>  In file included from boost_1_61_0\boost/date_time/posix_time/ptime.hpp:12:
1>  In file included from boost_1_61_0\boost/date_time/posix_time/posix_time_system.hpp:13:
1>  In file included from boost_1_61_0\boost/date_time/posix_time/posix_time_config.hpp:18:
1>  In file included from boost_1_61_0\boost/date_time/gregorian/gregorian_types.hpp:19:
1>  In file included from boost_1_61_0\boost/date_time/gregorian/greg_calendar.hpp:13:
1>  In file included from boost_1_61_0\boost/date_time/gregorian/greg_weekday.hpp:12:
1>  In file included from boost_1_61_0\boost/date_time/constrained_value.hpp:17:
1>  In file included from boost_1_61_0\boost/type_traits/is_base_of.hpp:12:
1>  In file included from boost_1_61_0\boost/type_traits/is_base_and_derived.hpp:13:
1>  boost_1_61_0\boost/type_traits/integral_constant.hpp:41:21: error: target of using declaration conflicts with declaration already in scope
1>        using ::mpl_::bool_;
1>                      ^
1>  boost_1_61_0\boost/type_traits/integral_constant.hpp:32:29: note: target of using declaration
1>     template <bool B> struct bool_;
1>                              ^
1>  boost_1_61_0\boost/mpl/bool.hpp:23:28: note: conflicting declaration
1>  template< bool C_ > struct bool_

clang is using these args: -m64 -fdeclspec -Wall -mcx16 -msse4 -stdlib=libstdc++ -g -ggdb3 -O1 -fno-exceptions -std=c++11 -Wextra -DBOOST_DATE_TIME_NO_LIB


Solution

  • Found this which is a similar error: https://svn.boost.org/trac10/ticket/12212

    Noticed that I had this defined for another lib, so I undef it for this include:

    #undef BOOST_MPL_CFG_NO_ADL_BARRIER_NAMESPACE
    #include <boost/interprocess/managed_shared_memory.hpp>
    #define BOOST_MPL_CFG_NO_ADL_BARRIER_NAMESPACE