In C, when using the name of the function in pthread_create is it the same as using a reference?

83 Views Asked by At

I'm not sure if I said it right.

   pthread_create(..., ..., &some, ...);
   ...is the same as:
   pthread_create(..., ..., some, ...);

I'm learning threads, if you could give a website or a video that makes it really simple, it would be great. Threads - locks, condition variables, etc. Thanks!

2

There are 2 best solutions below

0
On BEST ANSWER

You can use both function name some or pointer to function &some to get the address of the function.

Check also this answer.

0
On

Yes because function name is pointing to a memory location. In simple words it is a memory address, so you pass it like foo or &foo, both are the same.

Example Code:

#include <stdio.h>

int foo(){

    printf("hello world");

}

int (*fuu)();

int main (void)
{
   fuu = foo;
   fuu();

    return 0;
}

Hope this helps