gpt4 book ai didi

c++ - Boost Spirit调试输出未出现

转载 作者:行者123 更新时间:2023-12-02 10:11:15 26 4
gpt4 key购买 nike

我正在尝试this question的第二个答案。解析本身可以正常工作,但是在第一行取消对#define BOOST_SPIRIT_DEBUG的注释后,BOOST_SPIRIT_DEBUG输出仍然不会出现在任何地方。
当我将以下三行添加到main()时,我看到所有三行都出现在终端中。但是,我看不到任何解析器调试行。有什么不见了?

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。

最佳答案

我无法重现此内容:
Live On Coliru

#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, t, r, i, n, g]]</attributes>
    </value_>
    <success></success>
    <attributes>[[s, t, r, i, n, 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, t, r, i, n, g]]</attributes>
    </string_>
    <success>)</success>
    <attributes>[[s, t, r, i, n, g]]</attributes>
    </value_>
    <success>)</success>
    <attributes>[[s, t, r, i, n, g]]</attributes>
    </expr_>
    <success></success>
    <attributes>[[g, n, i, r, t, s]]</attributes>
    </function_call_>
    <success></success>
    <attributes>[[g, n, i, r, t, 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, t, r, i, n, g]]</attributes>
    </string_>
    <success>, 987)</success>
    <attributes>[[s, t, r, i, n, g]]</attributes>
    </value_>
    <success>, 987)</success>
    <attributes>[[s, t, r, i, n, 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, t, r, i, n, g, 9, 8, 7]]</attributes>
    </function_call_>
    <success></success>
    <attributes>[[s, t, r, i, n, g, 9, 8, 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, n, s, w, e, r, , I, s, ]]</attributes>
    </string_>
    <success>, AnswerToLTUAE())</success>
    <attributes>[[T, h, e, , A, n, s, w, e, r, , I, s, ]]</attributes>
    </value_>
    <success>, AnswerToLTUAE())</success>
    <attributes>[[T, h, e, , A, n, s, w, e, r, , I, s, ]]</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, h, e, , A, n, s, w, e, r, , I, s, , 4, 2]]</attributes>
    </function_call_>
    <success></success>
    <attributes>[[T, h, e, , A, n, s, w, e, r, , I, s, , 4, 2]]</attributes>
    </expr_>
    input: Concatenate('The Answer Is ', AnswerToLTUAE())
    eval: The Answer Is 42

    关于c++ - Boost Spirit调试输出未出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63470704/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com