我正在将我的代码从 boost 1.67 移植到 boost 1.74(debian buster->bullseye)。
当我编译时,我得到:
In file included from /usr/include/boost/config/header_deprecated.hpp:18,
from /usr/include/boost/detail/no_exceptions_support.hpp:15,
from /usr/include/boost/msm/back/state_machine.hpp:20,
from /home/stew/mycode.cpp:3:
/usr/include/boost/detail/no_exceptions_support.hpp:17:1: note: ‘#pragma message: This header is deprecated. Use <boost/core/no_exceptions_support.hpp> instead.’
17 | BOOST_HEADER_DEPRECATED("<boost/core/no_exceptions_support.hpp>")
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
36 | BOOST_PRAGMA_MESSAGE(
| ^~~~~~~~~~~~~~~~~~~~
我知道标题已被弃用。我很高兴改变#include <boost/bind.hpp> -> #include <boost/bind/bind.hpp>
#include <boost/detail/no_exceptions_support.hpp> -> #include <boost/core/no_exceptions_support.hpp>
但是问题不在我的代码中。它在 <boost/msm/back/state_machine.hpp>
.对于包含任何这些 header 的每个实例,我都会收到这样的错误:In file included from /usr/include/boost/bind.hpp:30,
from /usr/include/boost/property_tree/json_parser/detail/parser.hpp:7,
from /usr/include/boost/property_tree/json_parser/detail/read.hpp:13,
from /usr/include/boost/property_tree/json_parser.hpp:16:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
36 | BOOST_PRAGMA_MESSAGE(
| ^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/boost/math/tools/cxx03_warn.hpp:9,
from /usr/include/boost/math/constants/constants.hpp:11:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
36 | BOOST_PRAGMA_MESSAGE(
| ^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22,
from /usr/include/boost/smart_ptr/detail/yield_k.hpp:23,
from /usr/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14,
from /usr/include/boost/smart_ptr/detail/spinlock.hpp:42,
from /usr/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
from /usr/include/boost/smart_ptr/shared_ptr.hpp:29,
from /usr/include/boost/shared_ptr.hpp:17,
from /usr/include/boost/date_time/time_clock.hpp:17,
from /usr/include/boost/date_time/posix_time/posix_time_types.hpp:10,
from /usr/include/boost/asio/time_traits.hpp:23,
from /usr/include/boost/asio/detail/timer_queue_ptime.hpp:22,
from /usr/include/boost/asio/detail/deadline_timer_service.hpp:29,
from /usr/include/boost/asio/basic_deadline_timer.hpp:25,
from /usr/include/boost/asio.hpp:25:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
36 | BOOST_PRAGMA_MESSAGE(
| ^~~~~~~~~~~~~~~~~~~~
有没有办法在不修补 boost 本身的情况下使 boost 的内部警告静音?我知道我可以
-DBOOST_BIND_GLOBAL_PLACEHOLDERS
避免 bind
警告,但是 detail/no_exceptions_support.hpp
呢?问题?
最佳答案
你可以
BOOST_BIND_GLOBAL_PLACEHOLDERS
定义将使所有 bind.hpp
静音警告。从技术上讲,您应该更喜欢使用 BOOST_BIND_NO_PLACEHOLDERS
但有些库将不再工作(例如 Boost 属性树,至少对于某些后端而言)。关于c++ - 如何使内部 boost 已弃用的消息静音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66906613/