首页 文章

0x54FCC405抛出异常(sfml-system-d-2.dll)访问冲突读取位置0x00000017

提问于
浏览
-1
#include <SFML\Graphics.hpp>
#include <string>

using namespace sf;
using namespace std;

string calculate()
{
    static Clock clock = Clock();
    static float decimalTime = 0;

    decimalTime += clock.getElapsedTime().asSeconds();

    int decimalTimeIntPart = floorf(decimalTime);
    if (decimalTimeIntPart > decimalTime)
        decimalTimeIntPart--;
    float decimalTimeFractionalPart = decimalTime - decimalTimeIntPart;

    string binaryTimeStr;
    int n = decimalTimeIntPart;
    while (n != 0)
    {
        binaryTimeStr = to_string(n % 2) + binaryTimeStr;
        n = (n - n % 2) / 2;
    }

    binaryTimeStr += ".";
    float m = decimalTimeFractionalPart;
    int t = 4;
    while (m != 0 && t != 0)
    {
        m *= 2;
        if (m >= 1)
        {
            binaryTimeStr += "1";
            m--;
        }
        else
        {
            binaryTimeStr += "0";
        }
        t--;
    }

    clock.restart();
    return binaryTimeStr;
}

int main() 
{
    RenderWindow app(VideoMode(800, 600), "Heyyy!", !Style::Resize + Style::Close);

    Font font;
    font.loadFromFile("VT323-Regular.ttf");

    Text text("", font, 40);
    text.setColor(Color(234, 234, 234));
    text.setPosition(80, 280);

    while (app.isOpen())
    {
        Event e;
        while (app.pollEvent(e))
        {
            if (e.type == Event::Closed)
                app.close();
        }

        app.clear();

        text.setString(calculate());
        app.draw(text);

        app.display();
    }

    return 0;
}

它在调试模式下工作,但在发布模式下,我在my_ $ FML_stuff.exe中得到“异常抛出0x550DC405(sfml-system-d-2.dll):0xC0000005:访问冲突读取位置0x00000017 . ”

看起来我的帖子主要是代码,但我不知道还有什么要写,对不起 .

1 回答

  • 0

    这是因为当您在发布模式下运行时,您正在链接SFML的调试库

    sfml-system-d-2.dll
    

    -d表示调试,没有-d的那些dll用于发布模式 .

    你也可以从SFML的文档中看到它

    链接到与配置匹配的库非常重要:“sfml-xxx-d.lib”用于Debug,“sfml-xxx.lib”用于Release . 糟糕的混合可能会导致崩溃 .

相关问题