无法将参数传递给线程函数 [英] Can't pass arguments to thread function

查看:211
本文介绍了无法将参数传递给线程函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在尝试在c ++中创建一个运行函数storePose();的线程,该函数将9个参数作为双精度值.每次我尝试创建线程时,它都会抱怨参数.我将在下面发布我的代码.我不知道为什么这行不通.在此先感谢

Okay I am trying to make a thread in c++ that runs the function storePose(); that function takes nine parameters as doubles. Every time I try to create the thread it complains about the parameters. I will post my code below. I have not a clue why this wont work. Thanks in advanced

代码:

std::thread t(storePose,x_position, y_position, z_position, azimuth, att_pitch, att_roll, yaw, cam_pitch, cam_roll);
    t.detach();

错误:

    12  IntelliSense: no instance of constructor "std::thread::thread" matches the argument list
        argument types are: (<unknown-type>, double, double, double, double, double, double, double, double, double)

抱歉,我忘了提到我正在使用Visual Studio 2012

Sorry I forgot to mention that I am using Visual Studio 2012

推荐答案

Microsoft Visual C ++(2012)不支持可变参数模板.他们有一个叫做 faux variadics 的东西,可以通过宏消除过载.问题是您可以传递给可变参数模板的参数数目有一个限制,默认情况下该限制为5.您可以通过将_VARIADIC_MAX定义为更大的数目(例如,限制为10)来调整限制设置/D_VARIADIC_MAX=10)

Microsoft Visual C++ (2012) doesn't have support for variadic templates. They have something called faux variadics that stamp out overloads via macros. The problem is that there is a limit to the number of arguments you can pass to a variadic template and by default that limit is 5. You can adjust the limit by defining _VARIADIC_MAX to be a larger number (e.g. for a limit of 10 set /D_VARIADIC_MAX=10)

请参见.

这篇关于无法将参数传递给线程函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆