[英]Is it possible initialize a C's function pointer with a function declaration in the same line?
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.我想知道是否可以在 C 中使用函数声明来初始化函数指针,而无需事先声明它。
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!!提前致谢!!
It is impossible.是不可能的。 You may not use a declaration as an initializer because the initializer must be an expression.
您不能将声明用作初始化程序,因为初始化程序必须是表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.