Hi all,
I have encountered the above said error for some time. I have researched for possible solutions and have discovered that the error means that the function that I am calling as a thread is a member function. I have already declared the function as a global function, but yet the error still appears. Can anyone help me out here? The code is below. Thx in advance.
I have encountered the above said error for some time. I have researched for possible solutions and have discovered that the error means that the function that I am calling as a thread is a member function. I have already declared the function as a global function, but yet the error still appears. Can anyone help me out here? The code is below. Thx in advance.
Code:
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
bool orderStop=true;
bool firstTime=true;
bool stopRobo=false;
void *detectKey(void *arg)
{
int y;
std::cin >> y;
while (y != 1)
{
orderStop = true;
stopRobo = true;
}
return NULL;
pthread_exit(0);
}
void *detectKey(void *arg);
void
MainLoop::run()
{
pthread_t wait;
int rc;
.....
while ( isActive() )
{
try
{
....
if (orderStop)
{
....
// create thread to wait for keyboard input
rc = pthread_create(&wait,NULL,detectKey,NULL);
};
....
orderStop = false;
std::cout <<"\nBoolean orderStop is set at: " << orderStop <<endl;
}
catch(....){....}
}
}
Comment