调试期间双cout失败

时间:2016-02-18 06:39:59

标签: c++

当我尝试调试此代码段时,我感到很奇怪......很奇怪。

#include <iostream>
#include <conio.h>
#include "windows.h"
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

double frameCount;

int main()    
{
    frameCount = 18;
    std::cout << frameCount << std::endl;
    return 0;
}

它编译没问题。它甚至可以正常运行,但如果我逐行调试它,当我尝试将“frameCount”输出到控制台时程序会占用;

    std::cout << frameCount << std::endl;

通过将“frameCount”更改为int来解决此问题。以下是该行的调试器结果。

[debug]> next
[debug]0x004496f4 in std::ostream::operator<<(double) ()
[debug]>>>>>>cb_gdb:

In std::ostream::operator<<(double) () ()

[debug]> info locals
[debug]No symbol table info available.
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No symbol table info available.
[debug]>>>>>>cb_gdb:
[debug]> whatis frameCount
[debug]type = double
[debug]>>>>>>cb_gdb:
[debug]> output frameCount
[debug]1.8>>>>>>cb_gdb:
[debug]> bt 30
[debug]#0  0x004496f4 in std::ostream::operator<<(double) ()
[debug]#1  0x004165ae in __do_global_ctors ()
[debug]#2  0x004010fd in __mingw_CRTStartup ()
[debug]#3  0x00000001 in ?? ()
[debug]#4  0x7ffde000 in ?? ()
[debug]#5  0x7757ad1f in ?? ()
[debug]#6  0x7757acea in ?? ()
[debug]#7  0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:

1 个答案:

答案 0 :(得分:1)

出于您的目的,您不需要

#include <conio.h>
#include "windows.h"
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

以上标题。没有这些标题。好像没事。