-1

If void* makes a pointer that holds the address of any type, what does adding void* to the start of the function mean, why not just put void?

void* myFunction(void* arg)
{
    int thread_id = *((int*) arg);
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • Please add the full definition of the function, or at least the `return` statement at the end of the function if it exists. – cigien Mar 03 '21 at 02:45

1 Answers1

2

void *myFunction() means that myFunction returns "pointer to void", i.e. it returns a pointer, for which the type pointed to is not specified.

void myFunction() means that myFunction returns "void", i.e. it returns nothing at all.

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
  • 1
    It might have been better if the designers of C had chosen different names for these concepts, e.g. `arbitrary` for any type and `none` for no type. It would then be more clear that `arbitrary *myFunction()` returns a pointer, and `none myFunction()` returns nothing. But they didn't, so we're stuck with `void` playing both roles. – Nate Eldredge Mar 03 '21 at 02:52
  • `using none = void;` and `using arbitrary = void*;` :) – cigien Mar 03 '21 at 02:56