-2

And what's the difference between

void*(*void)(void*) 

and

void*(*voi)(void*)

and when to use it?

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Ochmar
  • 60
  • 8

1 Answers1

4

well void*(void)(void) doesn't compile, because it tries to declare a function that returns a void* named void and you can't use keywords of the language as names.

you can't declare an int named void either (int void=5; doesn't work of course).

Now voi is a valid identifier and you can name a function voi.

Trying to get at what you're actually asking the difference between.

void(*name)(void); and void(name)(void); is that one declares a function and the other declares a function pointer.
In fact the brackets on the second example don't do anything. void(name)(void); is the same as void name(void);.

However when declaring function pointers the brackets are needed or the * will bind left to the return type.

Anyway, I'm not sure what exactly you're asking, so you're best off searching the site for other questions regarding function pointers. Like this one that also explains why using void(name)(void) can be different from void(name)().

Community
  • 1
  • 1
PeterT
  • 7,981
  • 1
  • 26
  • 34