diff options
author | Robin Gareus <robin@gareus.org> | 2019-07-28 20:10:09 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-07-28 20:10:09 +0200 |
commit | 6d4b94df13e9a7df4270494d8376d4b81a0b2b9e (patch) | |
tree | c472d6a6a789f8332d21b6bfcbef38fd0966c0d9 /libs | |
parent | 684b364a8a471c6ca43822ddfe41f0580b0ec83b (diff) |
Reduce compiler warnings when boost uses std-atomics
This works around for compilers with non-static-data-member
initialization.
spinlock_t is-a struct { lockType _; } and BOOST_DETAIL_SPINLOCK_INIT
initializes the first member of the struct.
All defines of BOOST_DETAIL_SPINLOCK_INIT include c-style curly braces
to initialize the struct's data member.
However, modern C++ compiler interpret the braces differently resulting
in copy constriction of the initializer.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/pbd/spinlock.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libs/pbd/spinlock.cc b/libs/pbd/spinlock.cc index 45e35daf37..0e53b194b9 100644 --- a/libs/pbd/spinlock.cc +++ b/libs/pbd/spinlock.cc @@ -28,10 +28,17 @@ using namespace PBD; spinlock_t::spinlock_t () +#ifdef BOOST_SMART_PTR_DETAIL_SPINLOCK_STD_ATOMIC_HPP_INCLUDED + /* C++11 non-static data member initialization, + * with non-copyable std::atomic ATOMIC_FLAG_INIT + */ + : l {BOOST_DETAIL_SPINLOCK_INIT} {} +#else + /* default C++ assign struct's first member */ { - boost::detail::spinlock init = BOOST_DETAIL_SPINLOCK_INIT; - std::memcpy (&l, &init, sizeof (init)); + l = BOOST_DETAIL_SPINLOCK_INIT; } +#endif SpinLock::SpinLock (spinlock_t& lock) : _lock (lock) |