Reputation: 72
I wondered if it is possible to initialize a function pointer in C with the declaration of a function without the need to declare it previously.
Doing something like this:
FunctionPointer my_pointer = void MyFunction() {};
I know that likely you should do something like this:
void MyFunction() {}
my_pointer = MyFunction;
But I was interested to know if the compact's one is possible in some way.
Thanks in advance!!
Upvotes: 1
Views: 86
Reputation: 311058
It is impossible. You may not use a declaration as an initializer because the initializer must be an expression.
Upvotes: 1