NULL function pointers

后端 未结 3 1897
野性不改
野性不改 2021-01-17 11:04

What is the behavior of calling a null function pointer?

void (*pFunc)(void) = NULL;  
pFunc();

Why is it advisable to initialize yet unu

3条回答
  •  执念已碎
    2021-01-17 11:24

    It's advisable for the same reason as initializating "normal" (data) pointers to NULL: because it potentially makes some errors easier to track down. Opinions on whether this is useful or not of course vary :-)

提交回复
热议问题