di icon indicating copy to clipboard operation
di copied to clipboard

There is a conflict with boost

Open kanstantsin-chernik opened this issue 6 years ago • 4 comments

Expected Behavior

Boost and boost di should not have conflicts

Actual Behavior

As di.hpp defines __has_builtin the following code fails with an error error C3861: '__builtin_assume': identifier not found

#if defined( __has_builtin )
# if __has_builtin( __builtin_assume )
        __builtin_assume( local_use_count_ >= 1 );
# endif
#endif

Steps to Reproduce the Problem

  1. Include boost boost\smart_ptr\detail\local_counted_base.hpp after di.hpp
  2. Try to compile

Specifications

  • Version: 1.1
  • Platform: Windows
  • Subsystem: msvc

kanstantsin-chernik avatar Apr 27 '20 16:04 kanstantsin-chernik

@krzysztof-jusiak I think boost.di should define it's own aliases for these features

kanstantsin-chernik avatar Apr 27 '20 16:04 kanstantsin-chernik

I can do this if you think it is the way to go.

kanstantsin-chernik avatar Apr 27 '20 17:04 kanstantsin-chernik

Also, it is happening right into di.hpp

#if __has_include(<boost/shared_ptr.hpp>)
// clang-format on
#include <boost/shared_ptr.hpp>
#else

kanstantsin-chernik avatar Apr 27 '20 18:04 kanstantsin-chernik

Temporary fixed with workaround:

#if !defined(__builtin_assume)
#define __builtin_assume(...) 0
#endif
#define __has_builtin(...) 1

#define BOOST_DI_CFG_CTOR_LIMIT_SIZE 17

kanstantsin-chernik avatar Apr 27 '20 18:04 kanstantsin-chernik