Skip to content

Commit

Permalink
build: use BOOST_NO_CXX98_FUNCTION_BASE to suppress warnings
Browse files Browse the repository at this point in the history
Boost conatiner_hash (included via functional -> multi_index) uses
std::unary_function, which was deprecated in C++11, and "removed" in
C++17. It's use causes wanrings with newer compilers, i.e GCC 12.1.

```bash
/bitcoin/depends/aarch64-unknown-linux-gnu/include/boost/container_hash/hash.hpp:131:33:
warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations]
  131 |         struct hash_base : std::unary_function<T, std::size_t> {};
      |                                 ^~~~~~~~~~~~~~
In file included from /usr/include/c++/12/bits/unique_ptr.h:37,
                 from /usr/include/c++/12/memory:76,
                 from ./init.h:10,
                 from init.cpp:10:
/usr/include/c++/12/bits/stl_function.h:117:12: note: declared here
  117 |     struct unary_function
```

Use the MACRO outlined in
boostorg/container_hash#22, to prevent it's
use.

BOOST_NO_CXX98_FUNCTION_BASE:
> The standard library no longer supports std::unary_function and std::binary_function.
> They were deprecated in C++11 and is removed from C++14.

See:
boostorg/config#430
https://en.cppreference.com/w/cpp/utility/functional/unary_function
https://www.boost.org/doc/libs/master/libs/config/doc/html/boost_config/boost_macro_reference.html
  • Loading branch information
fanquake committed Jun 23, 2022
1 parent 1bdbbbd commit 880d4aa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,11 @@ if test "$use_boost" = "yes"; then
dnl we don't use multi_index serialization
BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION"

dnl Prevent use of std::unary_function, which was removed in C++17,
dnl and will generate warnings with newer compilers.
dnl See: https://github.com/boostorg/container_hash/issues/22.
BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_CXX98_FUNCTION_BASE"

if test "$enable_debug" = "yes" || test "$enable_fuzz" = "yes"; then
BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE"
fi
Expand Down

0 comments on commit 880d4aa

Please sign in to comment.