【问题标题】:boost spirit headers deprecated不推荐使用增强精神标题
【发布时间】:2009-05-29 06:19:16
【问题描述】:

我正在遵循 boost::spirit 的快速入门指南,当我包含以下内容时收到此编译器警告:“此标头已弃用。请使用:boost/spirit/include/classic_core.hpp” 我应该担心这个吗?

(快速入门指南:http://spirit.sourceforge.net/distrib/spirit_1_8_5/libs/spirit/doc/quick_start.html,这里包含我要编译的程序的完整源代码:http://spirit.sourceforge.net/distrib/spirit_1_8_5/libs/spirit/example/fundamental/number_list.cpp

编辑:此外,当我尝试使用推荐的 classic_core.hpp 和 classic_push_back_actor.hpp 头文件进行编译时,我收到以下编译器错误:

test7.cpp: In function 'bool parse_numbers(const char*, __gnu_debug_def::vector<double, std::allocator<double> >&)':
test7.cpp:18: error: 'real_p' was not declared in this scope
test7.cpp:18: error: 'push_back_a' was not declared in this scope
test7.cpp:23: error: 'space_p' was not declared in this scope
test7.cpp:23: error: 'parse' was not declared in this scope

【问题讨论】:

    标签: c++ boost boost-spirit


    【解决方案1】:

    [编辑:] 原来的答案已经严重过时了;特别是链接已损坏。 Boost 的当前版本(自 2012-02-24 起)是 1.49.0。

    提到的警告是 #include &lt;boost/spirit.hpp&gt; 的结果,这是一个已弃用的标头;但是网络上的旧示例使用这种形式。要开始使用,请尝试boost tutorials。一旦您看到正确的包含和命名空间,大多数旧示例都可以轻松转换。

    [旧答案:]

    您必须使用 boost 1.39 或更高版本(通过 SVN)。此演示文稿应该会有所帮助:

    简而言之,有一种全新的做事方式,这些是要使用的命名空间:

    • boost::spirit:qi(用于解析器)
    • boost::spirit::karma(用于生成器库)

    官方版本是 1.40,所以到那时文档可能会更新。

    编辑:the doc in the boost SVN repository 正在开发中,可能会以更忠实的方式反映新架构。

    【讨论】:

      【解决方案2】:

      当您包含经典标头时,解析器位于 boost::spirit::classic 命名空间中。试试:

      使用命名空间 boost::spirit::classic;

      【讨论】:

        【解决方案3】:

        当一个库指示一个类/头文件/方法/等时。已弃用,这意味着库的维护者很可能会停止维护该功能,并可能在将来将其删除。我会建议尽早切换到建议的标题,以免以后头疼。

        新标头处理功能的方式可能略有不同,因此您可能需要进行一些代码更改。

        (我对boost了解不多,这只是一般评论)

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2016-12-20
          • 2011-06-19
          • 1970-01-01
          • 1970-01-01
          • 2023-04-03
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多