liwenxiong0721 2023-10-18 11:14 采纳率: 33.3%
浏览 11
已结题

boost库statechart使用问题 std::allocator< none >


//adam_control.h
#include <boost/statechart/fifo_scheduler.hpp>
boost::statechart::fifo_scheduler<>::processor_handle m_state_machine_handle;
boost::scoped_ptr<boost::thread> m_state_machine_thread;
//boost1.78.0+opencv4.6.0编译报错
In file included from /usr/local/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22,
                 from /usr/local/include/boost/smart_ptr/detail/yield_k.hpp:23,
                 from /usr/local/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14,
                 from /usr/local/include/boost/smart_ptr/detail/spinlock.hpp:42,
                 from /usr/local/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
                 from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:29,
                 from /usr/local/include/boost/log/core/core.hpp:19,
                 from /usr/local/include/boost/log/utility/setup/common_attributes.hpp:20,
                 from /home/lwx/firm178/hal/../infra/log.h:5,
                 from /home/lwx/firm178/application/componentbuilder.h:3,
                 from /home/lwx/firm178/application/componentbuilder.cpp:1:
/usr/local/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/local/include/boost/statechart/fifo_scheduler.hpp:12,
                 from /home/lwx/firm178/application/control/adam_control.h:13,
                 from /home/lwx/firm178/application/componentbuilder.cpp:8:
/usr/local/include/boost/statechart/fifo_worker.hpp:55:50: error: type/value mismatch at argument 1 in template parameter list for ‘template<class> class std::allocator’
   55 | template< class Allocator = std::allocator< none > >
      |                                                  ^
/usr/local/include/boost/statechart/fifo_worker.hpp:55:50: note:   expected a type, got ‘boost::none’
In file included from /usr/local/include/boost/statechart/fifo_scheduler.hpp:13,
                 from /home/lwx/firm178/application/control/adam_control.h:13,
                 from /home/lwx/firm178/application/componentbuilder.cpp:8:
/usr/local/include/boost/statechart/processor_container.hpp:63:42: error: type/value mismatch at argument 1 in template parameter list for ‘template<class> class std::allocator’
   63 |   class Allocator = std::allocator< none > >
      |                                          ^
/usr/local/include/boost/statechart/processor_container.hpp:63:42: note:   expected a type, got ‘boost::none’
In file included from /home/lwx/firm178/application/control/adam_control.h:13,
                 from /home/lwx/firm178/application/componentbuilder.cpp:8:
/usr/local/include/boost/statechart/fifo_scheduler.hpp:30:34: error: template argument 1 is invalid
   30 |   class FifoWorker = fifo_worker<>,
      |                                  ^
/usr/local/include/boost/statechart/fifo_scheduler.hpp:31:42: error: type/value mismatch at argument 1 in template parameter list for ‘template<class> class std::allocator’
   31 |   class Allocator = std::allocator< none > >
      |                                          ^
/usr/local/include/boost/statechart/fifo_scheduler.hpp:31:42: note:   expected a type, got ‘boost::none’
In file included from /home/lwx/firm178/application/componentbuilder.cpp:8:
/home/lwx/firm178/application/control/adam_control.h:93:39: error: template argument 1 is invalid
   93 |     boost::statechart::fifo_scheduler<> m_state_machine_scheduler;
      |                                       ^
/home/lwx/firm178/application/control/adam_control.h:93:39: error: template argument 2 is invalid
/home/lwx/firm178/application/control/adam_control.h:94:39: error: template argument 1 is invalid
   94 |     boost::statechart::fifo_scheduler<>::processor_handle m_state_machine_handle;
      |                                       ^
/home/lwx/firm178/application/control/adam_control.h:94:39: error: template argument 2 is invalid
/home/lwx/firm178/application/control/adam_control.h:94:42: error: expected ‘;’ at end of member declaration
   94 |     boost::statechart::fifo_scheduler<>::processor_handle m_state_machine_handle;
      |                                          ^~~~~~~~~~~~~~~~
      |                                                          ;
/home/lwx/firm178/application/control/adam_control.h:94:59: error: ‘m_state_machine_handle’ does not name a type
   94 |     boost::statechart::fifo_scheduler<>::processor_handle m_state_machine_handle;
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [application/CMakeFiles/firmware_adam.dir/build.make:90:application/CMakeFiles/firmware_adam.dir/componentbuilder.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:264:application/CMakeFiles/firmware_adam.dir/all] 错误 2
make: *** [Makefile:146:all] 错误 2
//问题:在boost1.61.0+opencv3.1.0及c++98下编译不报错,在boost1.78.0+opencv4.6.0及c++17下编译报上述错误,请问哪位知道怎么解决吗,非常感觉
  • 写回答

10条回答 默认 最新

  • 呈两面包夹芝士 2023-10-19 17:01
    关注

    引自GPT
    这个问题是由于Boost库的版本不兼容导致的。在Boost 1.78.0及更高版本中,std::allocator<none>已被弃用,取而代之的是std::allocator<void>。为了解决这个问题,你可以尝试将代码中的std::allocator<none>替换为std::allocator<void>

    首先,找到以下代码:

    template< class Allocator = std::allocator< none > >
    

    将其替换为:

    template< class Allocator = std::allocator< void > >
    

    然后,找到以下代码:

    boost::statechart::fifo_worker<>,
    

    将其替换为:

    boost::statechart::fifo_worker<>,
    

    最后,找到以下代码:

    boost::statechart::processor_container<>,
    

    将其替换为:

    boost::statechart::processor_container<>,
    

    完成这些更改后,重新编译项目,问题应该得到解决。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?

问题事件

  • 系统已结题 10月31日
  • 已采纳回答 10月23日
  • 创建了问题 10月18日

悬赏问题

  • ¥15 vs code配置c语言遇到这个问题
  • ¥15 vscode调试编译找不到gcc,只有cl,但是检查cmd是对的,控制面板的路径也更改了
  • ¥20 access中怎么分割分别获取一下图中的值
  • ¥15 keras_tcn已经安装成功,还是显示ModuleNotFoundError: No module named 'keras_tcn'
  • ¥15 ENVI高分五号去除云层的方法
  • ¥15 16进制数据如何得到奇偶校验位
  • ¥15 求合并两个字节流VB6代码
  • ¥15 Pyqt 如何正确的关掉Qthread,并且释放其中的锁?
  • ¥30 网站服务器通过node.js部署了一个项目!前端访问失败
  • ¥15 WPS访问权限不足怎么解决