Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 运行时检查失败#未保存dll值中的0_C++_Dll_Runtime_Visual Studio 2019 - Fatal编程技术网

C++ 运行时检查失败#未保存dll值中的0

C++ 运行时检查失败#未保存dll值中的0,c++,dll,runtime,visual-studio-2019,C++,Dll,Runtime,Visual Studio 2019,我似乎不明白为什么它会这样做 unsigned long drawing::font; auto drawing::setup_fonts() -> void { drawing::font = g_surface->CreateFont_(); g_surface->SetFontGlyphSet(drawing::font, "Small Fonts", 8, 400, 0, 0, sdk::FONTFLAG_OUTLINE); } a

我似乎不明白为什么它会这样做

unsigned long drawing::font;
auto drawing::setup_fonts() -> void
{
    drawing::font = g_surface->CreateFont_();
    g_surface->SetFontGlyphSet(drawing::font, "Small Fonts", 8, 400, 0, 0, sdk::FONTFLAG_OUTLINE);
}

auto drawing::render_text(int x, int y, Color clr, const char* fmt, ...) -> void
{
    va_list va_alist;
    char buffer[1024] = { '\0' };
    wchar_t str[1024] = { '\0' };

    va_start(va_alist, fmt);
    vsprintf(buffer, fmt, va_alist);
    va_end(va_alist);

    swprintf(str, 1024, L"%s", buffer);

    g_surface->DrawSetTextPos(x, y);
    g_surface->DrawSetTextFont(drawing::font);
    g_surface->DrawSetTextColor(clr);
    g_surface->DrawPrintText(str, wcslen(str));
}
它在两个函数中都给了我这个错误,第二个在右括号中,第一个错误是这一行

drawing::font = g_surface->CreateFont_();
名称空间图形定义

namespace drawing
{
    auto setup_fonts() -> void;
    auto render_text(int x, int y, Color clr, const char* fmt, ...) -> void;
    extern unsigned long font;
}
g_表面def

sdk::ISurface* g_surface;
extern sdk::ISurface*         g_surface;

g_surface = get_interface<sdk::ISurface>("vguimatsurface.dll", VGUIMAT_SURFACE_INTERFACE_VERSION);


template <class T>
auto get_interface(const char* module, const char* name) -> T*
{
    return reinterpret_cast<T*>(platform::get_interface(module, name));
}

在debugger中,我检查了g_surface是否为nullptr。

DLL中的调用约定可能与您假设的不同。我还有其他接口,它们的访问方式和定义方式相同。甚至可以在代码中的其他地方访问此接口。可能是链接器问题吗?可能是链接器问题,您可以检查连接的dll是否正确。
class ISurface
    {
    public:
        ...
        virtual vgui::HFont   CreateFont_() = 0;
        virtual bool          SetFontGlyphSet(vgui::HFont font, const char* windowsFontName, int tall, int weight, int blur, int scanlines, int flags, int nRangeMin = 0, int nRangeMax = 0) = 0;
        ...
    };