Why should anyone compare function pointers? Here’s one example:
#include <stdbool.h>
/*
* Register a function to be executed on event. A function may only be registered once.
* Input:
* arg - function pointer
* Returns:
* true on successful registration, false if the function is already registered.
*/
bool register_function_for_event(void (*arg)(void));
/*
* Un-register a function previously registered for execution on event.
* Input:
* arg - function pointer
* Returns:
* true on successful un-registration, false if the function was not registered.
*/
bool unregister_function_for_event(void (*arg)(void));
The body of register_function_for_event
only sees arg
. It doesn’t see any function name. It must compare function pointers to report someone is registering the same function twice.
And if you want to support something like unregister_function_for_event
to complement the above, the only information you have is the function address. So you again would need to pass it in, and compare against it, to allow removal.
As for the richer information, yes. When the function type contains a prototype, it’s part of the static type information. Mind you that in C a function pointer can be declared without a prototype, but that is an obsolescent feature.