Connecting Tech Pros Worldwide Help | Site Map

Error regarding 3rd parameter of pthread_create()

Newbie
 
Join Date: Mar 2008
Posts: 12
#1: Mar 16 '08
Could someone please explain to me the return type of pthread_create()'s 3rd parameter? I know it should be a function but I keep getting the error: argument of type 'void' (Test::)(void*)' does not match 'void * (*) (void*)'.

Here is the function that I pass to pthread_create():
Expand|Select|Wrap|Line Numbers
  1. void * Test::run(void * arg)
  2. {   cout << "Running...";
  3. }
  4.  
And this is how I call pthread_create():
Expand|Select|Wrap|Line Numbers
  1. pthread_create(&aThread,NULL,run,NULL);
  2.  
Moderator
 
Join Date: Mar 2007
Location: North Bend Washington USA
Posts: 5,366
#2: Mar 16 '08

re: Error regarding 3rd parameter of pthread_create()


Test::run has to be a static function to avoid the compiler supplying the this pointer in as the first argument.
Reply