异步函数出错

error in async function

本文关键字:出错 函数 异步      更新时间:2023-10-16

我想用std::async为静态类测试以下函数,我的主要目标是等待函数执行。但我面临着以下错误。有人能告诉我这个错误的原因吗。

IASD* ASDInterface = getASD();//gets the instance corrcet and tested function successfully
auto habnd = std::async(std::launch::async, &IASD::handle_request, ASDInterface ,arb_id, sid, data, size);

在调试了上面的行之后,我得到了以下错误。

错误LNK2019:函数"protected:__thiscall Concurrent::details::_RefCounter::_Ref Counter(long)"中引用了未解析的外部符号__imp___CrtDbgReportW(??)??0_RefCounter@details@并发@@IAE@J@Z)

有人能回答我为什么会犯以上错误吗。

非常感谢。

我不认为它与std::async直接相关,
我怀疑代码生成选项卡上的运行时选项不匹配

确保在degub构建时,"运行库"设置为"多线程调试/MTd"或"多线程调试器DLL/MDd"
(项目->属性->配置属性->C/C++->代码生成->运行库)