What is the function of an asterisk before a function name?

Solution 1:

The asterisk belongs to the return type, and not to the function name, i.e.:

void* func_name(void *param) { . . . . . }

It means that the function returns a void pointer.

Solution 2:

The * refers to the return type of the function, which is void *.

When you declare a pointer variable, it is the same thing to put the * close to the variable name or the variable type:

int *a;
int* a;

I personally consider the first choice more clear because if you want to define multiple pointers using the , separator, you will have to repeat the * each time:

int *a, *b;

Using the "close to type syntax" can be misleading in this case, because if you write:

int* a, b;

You are declaring a pointer to int (a) and an int (b).

So, you'll find that syntax in function return types too!

Solution 3:

The * belongs to the return type. This function returns void *, a pointer to some memory location of unspecified type.

A pointer is a variable type by itself that has the address of some memory location as its value. The different pointer types in C represent the different types that you expect to reside at the memory location the pointer variable refers to. So a int * is expected to refer to a location that can be interpreted as a int. But a void * is a pointer type that refers to a memory location of unspecified type. You will have to cast such a void pointer to be able to access the data at the memory location it refers to.

Solution 4:

It means that the function returns a void*.