不赞成提升精神标题

Sam*_*Lee 6 c++ boost boost-spirit

我正在关注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
Run Code Online (Sandbox Code Playgroud)

小智 11

[编辑:]原来的答案严重过时了; 特别是链接被打破了.Boost的当前版本(自2012-02-24以来)为1.49.0.

提到的警告#include <boost/spirit.hpp>是一个不推荐使用的标题; 但是网上的旧例子使用这种形式.要开始使用,请尝试使用boost教程.一旦看到正确的包含和名称空间,就可以轻松转换大多数旧示例.

[老答案:]

您必须使用boost 1.39或更高版本(通过SVN).此演示文稿应有助于:

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

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

官方发布的版本是1.40,因此可能会更新文档.

编辑:boost SVN存储库中的doc正在开发中,并且可能以更忠实的方式反映新架构.