How does dereferencing of a function pointer happen?
Posted
by eSKay
on Stack Overflow
See other posts from Stack Overflow
or by eSKay
Published on 2010-05-08T20:50:47Z
Indexed on
2010/05/08
20:58 UTC
Read the original article
Hit count: 271
Why and how does dereferencing a function pointer just "do nothing"?
This is what I am talking about:
#include<stdio.h>
void hello() { printf("hello"); }
int main(void) {
(*****hello)();
}
From a comment over here:
function pointers dereference just fine, but the resulting function designator will be immediately converted back to a function pointer
And from an answer here:
Dereferencing (in way you think) a function's pointer means: accessing a CODE memory as it would be a DATA memory.
Function pointer isn't suppose to be dereferenced in that way. Instead, it is called.
I would use a name "dereference" side by side with "call". It's OK.
Anyway: C is designed in such a way that both function name identifier as well as variable holding function's pointer mean the same: address to CODE memory. And it allows to jump to that memory by using call () syntax either on an identifier or variable.
How exactly does dereferencing of a function pointer work?
© Stack Overflow or respective owner