You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

全局对象析构函数未被调用的原因咨询

全局对象析构函数未被调用的原因咨询

我遇到个问题想请教下:我在和main()函数同一个源文件里定义了一个全局对象,代码是这样的:

DSS::TraceControl traceControl{ std::source_location::current().file_name() };

这个对象负责在main()启动前初始化我的应用追踪功能,目前这部分运行得挺正常的。

它的析构函数代码如下:

TraceControl::~TraceControl()
{
    OutputDebugStringA("TraceControl destructor\n");
    if (erase)
    {
        OutputDebugStringA("erase is true: Erasing trace logs...");
    }
}

但我发现这个全局对象的析构函数好像没被调用,想问问这可能是什么原因导致的呀?

备注:内容来源于stack exchange,提问作者David Partridge

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 16:12:58