0

Hi,

I'm trying to create a thread for running some tasks. I copied the code from an old console application (which compiles fine), but can't figure out why it's not working now. I have searched for the error code and came across this suggestion: "Are you passing the name of a member function as a parameter accidentally?" :-O

Lift.h:

void operateIt(void *);

Lift.cpp:

void Lift::operate(int aCurrentFloor) {
	//start thread that looks at the queue and moves between floors
	_beginthread(operateIt, 5, &aCurrentFloor);
}

void Lift::operateIt(void * arg) {

	int s = *( (int*) arg );

	while(1){
   		//do magic
	}
	_endthreadex(1);
}

Errors:

IntelliSense: argument of type "void (Lift::*)(void *arg)" is incompatible with parameter of type "void (__cdecl *)(void *)"

error C3867: 'Lift::operateIt': function call missing argument list; use '&Lift::operateIt' to create a pointer to member	c:\users\alex\documents\visual studio 2010\projects\proiectsctr\proiectsctr\lift.cpp	20

Any help is appreciated.

Edit: the problem has been fixed after declaring the operateIt method static.

Edited by Buffalo101: n/a

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by jmichae3
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.