Hmmm. Maybe I'm wrong about not using NULL for function pointers. Refer to
C FAQ 5.8.
NULL is the null pointer value for
data pointers. The C Standard permits compiler implementations to use different encoding rules for data pointers and function pointers if that makes sense for the particular environment. Portable code does not assign data pointer values to function pointers or vice-versa. Thus, portable code will not assign NULL to function pointers. The portable null pointer value for function pointers is the bare integer
0. I have been known to use the following private macro for the null function pointer constant:
By the way, the "%p" format code for
printf is for data pointers. I can't think of a maximally portable way to print out the value of a function pointer.