Error regarding 3rd parameter of pthread_create()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • unclefester
    New Member
    • Mar 2008
    • 12

    Error regarding 3rd parameter of pthread_create()

    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( ):
    Code:
    void * Test::run(void * arg)
    {   cout << "Running...";
    }
    And this is how I call pthread_create( ):
    Code:
    pthread_create(&aThread,NULL,run,NULL);
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

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

    Comment

    Working...