如何解决Boost Spirit调试输出未出现
我正在尝试this question的第二个答案。解析本身可以正常工作,但是在第一行取消对#define BOOST_SPIRIT_DEBUG
的注释后,BOOST_SPIRIT_DEBUG
输出仍然不会出现在任何地方。
当我将下面的这3行添加到main()
时,我看到所有3行都出现在终端中。但是,我看不到任何解析器调试行。缺少什么?
std::cout << "Hello cout" << std::endl;
std::cerr << "Hello cerr" << std::endl;
BOOST_SPIRIT_DEBUG_OUT << "Hello boost spirit debug out" << std::endl;
也许值得一提,我正在使用Qt Creator。
解决方法
我无法复制:
#define BOOST_SPIRIT_DEBUG
#include <boost/spirit/include/qi.hpp>
int main() {
std::cout << "Hello cout" << std::endl;
std::cerr << "Hello cerr" << std::endl;
BOOST_SPIRIT_DEBUG_OUT << "Hello boost spirit debug out" << std::endl;
}
打印
Hello cout
Hello cerr
Hello boost spirit debug out
所有常见的罪魁祸首是:
- 过时建造
- 运行与生成的二进制文件不同的二进制文件
- 预编译的标题毁了您的一天?当您在预编译标头包含之前包含任何内容时,[在我知道的任何编译器中]都会导致警告,但请注意以防万一。
以下是第二个答案演示 Live On Coliru 与调试输出(或without)的链接:
<expr_>
<try>-99</try>
<function_call_>
<try>-99</try>
<fail/>
</function_call_>
<value_>
<try>-99</try>
<success></success>
<attributes>[-99]</attributes>
</value_>
<success></success>
<attributes>[-99]</attributes>
</expr_>
input: -99
eval: -99
<expr_>
<try>'string'</try>
<function_call_>
<try>'string'</try>
<fail/>
</function_call_>
<value_>
<try>'string'</try>
<string_>
<try>'string'</try>
<success></success>
<attributes>[[s,t,r,i,n,g]]</attributes>
</string_>
<success></success>
<attributes>[[s,g]]</attributes>
</value_>
<success></success>
<attributes>[[s,g]]</attributes>
</expr_>
input: 'string'
eval: string
<expr_>
<try>AnswerToLTUAE()</try>
<function_call_>
<try>AnswerToLTUAE()</try>
<success></success>
<attributes>[42]</attributes>
</function_call_>
<success></success>
<attributes>[42]</attributes>
</expr_>
input: AnswerToLTUAE()
eval: 42
<expr_>
<try>ReverseString('strin</try>
<function_call_>
<try>ReverseString('strin</try>
<expr_>
<try>'string')</try>
<function_call_>
<try>'string')</try>
<fail/>
</function_call_>
<value_>
<try>'string')</try>
<string_>
<try>'string')</try>
<success>)</success>
<attributes>[[s,g]]</attributes>
</string_>
<success>)</success>
<attributes>[[s,g]]</attributes>
</value_>
<success>)</success>
<attributes>[[s,g]]</attributes>
</expr_>
<success></success>
<attributes>[[g,s]]</attributes>
</function_call_>
<success></success>
<attributes>[[g,s]]</attributes>
</expr_>
input: ReverseString('string')
eval: gnirts
<expr_>
<try>Concatenate('string'</try>
<function_call_>
<try>Concatenate('string'</try>
<expr_>
<try>'string',987)</try>
<function_call_>
<try>'string',987)</try>
<fail/>
</function_call_>
<value_>
<try>'string',987)</try>
<string_>
<try>'string',987)</try>
<success>,987)</success>
<attributes>[[s,g]]</attributes>
</string_>
<success>,987)</success>
<attributes>[[s,g]]</attributes>
</value_>
<success>,987)</success>
<attributes>[[s,g]]</attributes>
</expr_>
<expr_>
<try> 987)</try>
<function_call_>
<try> 987)</try>
<fail/>
</function_call_>
<value_>
<try> 987)</try>
<success>)</success>
<attributes>[987]</attributes>
</value_>
<success>)</success>
<attributes>[987]</attributes>
</expr_>
<success></success>
<attributes>[[s,g,9,8,7]]</attributes>
</function_call_>
<success></success>
<attributes>[[s,7]]</attributes>
</expr_>
input: Concatenate('string',987)
eval: string987
<expr_>
<try>Concatenate('The Ans</try>
<function_call_>
<try>Concatenate('The Ans</try>
<expr_>
<try>'The Answer Is ',An</try>
<function_call_>
<try>'The Answer Is ',An</try>
<fail/>
</function_call_>
<value_>
<try>'The Answer Is ',An</try>
<string_>
<try>'The Answer Is ',An</try>
<success>,AnswerToLTUAE())</success>
<attributes>[[T,h,e,A,s,w,I,]]</attributes>
</string_>
<success>,AnswerToLTUAE())</success>
<attributes>[[T,]]</attributes>
</value_>
<success>,AnswerToLTUAE())</success>
<attributes>[[T,]]</attributes>
</expr_>
<expr_>
<try> AnswerToLTUAE())</try>
<function_call_>
<try> AnswerToLTUAE())</try>
<success>)</success>
<attributes>[42]</attributes>
</function_call_>
<success>)</success>
<attributes>[42]</attributes>
</expr_>
<success></success>
<attributes>[[T,4,2]]</attributes>
</function_call_>
<success></success>
<attributes>[[T,2]]</attributes>
</expr_>
input: Concatenate('The Answer Is ',AnswerToLTUAE())
eval: The Answer Is 42
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。