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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.