0

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

CODE:

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

ERROR GIVEN:

    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)

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

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190

2 Answers2

1

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)

See this and this.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
JP Flouret
  • 578
  • 4
  • 6
  • thank you, that could help me, where exactly do i put that to set it? Sorry im newer to this type of programming – Jake Hewitt Nov 13 '14 at 22:39
  • Right click on your project in Solution Explorer. Select Properties... and naviagete to C/C++ -> Preprocessor and set add _VARIADIC_MAX=10 to "Preprocessor Definitions". Make sure you do that for all the configurations of the project (debug, release, etc.) – JP Flouret Nov 13 '14 at 22:44
  • Thank you so so much. I have been messing with this for hours and that is a bit too high level for me to have gotten! Thank you again so much, and I'm not to sure why it got down voted twice if I was able to get a good answer! THANK YOU! – Jake Hewitt Nov 13 '14 at 22:48
  • If you don't mind looking at my new [Question HERE](http://stackoverflow.com/questions/27388068/boostthread-thread-not-accepting-arguments) I have this error again after switching to the Boost threads. – Jake Hewitt Dec 09 '14 at 20:22
-1

Too many arguments, put them in a struct and give the struct to the thread function and deal with the args in the struct.

Etixpp
  • 320
  • 2
  • 11
  • i will try this, but i did try to put the arguments in a vector and just overloaded the funciton and it still gave me an error that was very similar – Jake Hewitt Nov 13 '14 at 22:31
  • Does the signature of the storePos function match the given arguments? – Etixpp Nov 13 '14 at 22:33
  • yes the funciton is declared in my header as this: `void storePose(double lat, double lon, double alt, double attYaw, double attPitch, double attRoll, double camYaw, double camPitch, double camRoll);` – Jake Hewitt Nov 13 '14 at 22:35
  • and it was `void storePose(vector params);` when i tried that – Jake Hewitt Nov 13 '14 at 22:35