ZBLOG

Module_Status function1(Recipe &recipe) { printf("set plate temp thread start\n"); if (SYS_ABORTED == RUN_FUNCTIONF(Temp_Ctrl, "set-plate %.2f %.2f %.2f", recipe.GetSingleStep().plateTarget, recipe.GetSingleStep().plateAlarm, recipe.GetSin...

你的代码中出现了错误。 _beginthread 函数需要一个指向线程入口点函数的指针作为第一个参数,而你却直接传递了 function1(recipe) 的调用结果。这导致编译器无法将 Module_Status 类型转换为 _beginthread_proc_type 类型。

要解决这个问题,你应该创建一个静态或全局函数,并将其作为线程入口点,在该函数内部调用 function1(recipe)。下面是修改后的示例代码:

unsigned int __stdcall ThreadFunc(void* arg) {
    Recipe& recipe = *static_cast<Recipe*>(arg);
    
    printf("set plate temp thread start\n");
    if (SYS_ABORTED == RUN_FUNCTIONF(Temp_Ctrl, "set-plate %.2f %.2f %.2f", recipe.GetSingleStep().plateTarget, recipe.GetSingleStep().plateAlarm, recipe.GetSingleStep().plateStop))
    {
        return Global::ModuleStatus(SYS_ABORTED);
    }
    
    _endthread();
    return 0;
}

// 在合适的位置调用 _beginthread
Recipe myRecipe; // 假设有一个 Recipe 对象
_beginthread(ThreadFunc, 0, &myRecipe);

在上述示例中,我们创建了名为 ThreadFunc 的静态函数作为线程入口点,在其中将 arg 转换为 Recipe& 引用,并进行相应操作。然后我们通过 _beginthread 调用 ThreadFunc 并传递相关参数。

请根据你的实际需求和代码结构进行适当修改。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://sdn.0voice.com/?id=4157

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?