what is the difference between these two below:
typedef void (*my_destructor)(void *);
typedef void (*my_destructor)(void *) my_func_ptr;
is the second one valid?
what is the difference between these two below:
typedef void (*my_destructor)(void *);
typedef void (*my_destructor)(void *) my_func_ptr;
is the second one valid?
The first one declares a type called my_destructor
. This type is a pointer to a function taking a parameter of type void*
and returning nothing.
The second one is not valid, what are you trying to do ? If you want to declare a variable of type my_destructor
, you have to do this:
typedef void (*my_destructor)(void *);
my_destructor my_func_ptr;
You are declaring a type for a pointer function.
The first one is the good one it mean you have a type named my_destructor who is a pointer to a function (*my_destructor)
that take a void pointer (void *)
on arguments and who return nothing (void
).
Now you can use your type as if it was another type like for example char, long or whatever.