我可以使用指向静态函数的函数指针,例如指向非静态函数的函数指针吗?
Can I use function pointers to static functions like function pointers to non-static functions?
我可以像使用指向非静态函数的指针那样使用指向静态函数的指针吗?
假设我有:
void (*fp_some_event_handler)(void);
void KeyEventHandler(void){
// not static
}
static void KeyEventHandlerStatic(void){
// static
}
我可以像非静态一样使用静态函数指针吗?
void main() {
// now I have something like this
fp_some_event_handler = KeyEventHandler;
// and I want to change some function to static and end with this
fp_some_event_handler = KeyEventHandlerStatic;
}
函数是否 static
不是其类型的一部分,而是 存储 class 说明符.
因此您可以将示例代码中的两个函数中的任何一个分配给函数指针fp_some_event_handler
。
我可以像使用指向非静态函数的指针那样使用指向静态函数的指针吗?
假设我有:
void (*fp_some_event_handler)(void);
void KeyEventHandler(void){
// not static
}
static void KeyEventHandlerStatic(void){
// static
}
我可以像非静态一样使用静态函数指针吗?
void main() {
// now I have something like this
fp_some_event_handler = KeyEventHandler;
// and I want to change some function to static and end with this
fp_some_event_handler = KeyEventHandlerStatic;
}
函数是否 static
不是其类型的一部分,而是 存储 class 说明符.
因此您可以将示例代码中的两个函数中的任何一个分配给函数指针fp_some_event_handler
。