boost-ext / di

C++14 Dependency Injection Library
https://boost-ext.github.io/di
1.13k stars 137 forks source link

There is a conflict with boost #466

Open kanstantsin-chernik opened 4 years ago

kanstantsin-chernik commented 4 years ago

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

kanstantsin-chernik commented 4 years ago

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

kanstantsin-chernik commented 4 years ago

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

kanstantsin-chernik commented 4 years ago

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 commented 4 years ago

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