lundi 7 décembre 2015

pthread in cpp for different member functions in a class

i started with a simple example http://ift.tt/1zrMMN6 i need to divide in the different cpps and headers i have as the following

class definition in Process_Images.h

void PrintHello(void* threadid);

in Process_Images.cpp

void ProcessImages::PrintHello(void* threadid)
{
   long tid;
   tid = (long)threadid;
   std::cout << "Hello World! Thread ID, " << tid << std::endl;
   pthread_exit(NULL);
}

in the main function

ProcessImages PI;

pthread_t threads[2];
pthread_create(&threads[0],NULL,PI.PrintHello,(void *)i);

the error is -->

/home/nvidia/Desktop/cms/tools/vibrante-vcm30t124-linux/cmsapplication_export/cmsapplication/sampleThread.cpp:333:69: error: cannot convert ���ProcessImages::PrintHello��� from type ���void (ProcessImages::)(void*)��� to type ���void* (*)(void*)���
      pthread_create(&threads[0],NULL,CarDetLEFT.PrintHello,(void *)i);
                                                                     ^

any suggestion please?

Aucun commentaire:

Enregistrer un commentaire