Is it possible initialize a C's function pointer with a function declaration in the same line?

76 Views Asked by At

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!!

1

There are 1 best solutions below

0
On BEST ANSWER

It is impossible. You may not use a declaration as an initializer because the initializer must be an expression.