Reputation: 9783
I saw this one in one of the .h files provided by my professor for a project, but I'm not too sure what this means.
int (*get_console_dev)(void);
Is it the same as
(int*) get_console_dev(void);
(a function named get_console_dev, which returns a pointer to an int
?)
Thanks
Upvotes: 1
Views: 79
Reputation: 59607
int (*get_console_dev)(void)
is a function pointer declaration. get_console_dev
is a variable that can hold a reference to a function matching the specific signature.
int consoleFunction(void);
// ...
int (*get_console_dev)(void);
get_console_dev = consoleFunction;
This declaration is not the same as: (int*) get_console_dev(void);
.
Check this with cdecl.
Upvotes: 3
Reputation: 1
Please read up function pointers. it is a pointer to a function that takes void (as argument) and returns integer
Upvotes: 0
Reputation: 810
int (*get_console_dev)(void);
This is Pointer pointer function with no parameter and return type as integer.
(int*) get_console_dev(void);
This is function with no parameter and return type as pointer of type integer.
Both are completely different.
Upvotes: 0
Reputation: 182619
It's a function pointer that can point to a function returning int
and taking 0 parameters; it's not equivalent to the second line you posted.
Upvotes: 7