On Tue, 10 Oct 2017, Martin Sebor wrote: > Calling a function that takes arguments via a void (*)(void) > is undefined not just on paper but also in practice, so the > resulting pointer from such a cast is unusable except to convert > to a compatible pointer.
That's the point of a generic pointer - it either gets cast to the actual type (or something ABI-compatible with the actual type) for calls, or called from non-C code which has the same effect. > PS It would be useful if modern C provided a clean mechanism to > support generic function pointers rather that forcing users leery > of relying on obsolescent features to invent workarounds. One You can use any function pointer type whatever as your generic pointer (casting back to the original type for calls). That you can cast from one function pointer type to another and back to the original type is guaranteed by ISO C. That the result of the conversion is meaningful for calls from non-C languages is part of the customary practices of C implementations. That the type used is void (*) (void) is a common convention used in C code dealing with generic function pointers (another convention, of course, is just using void * as in POSIX and relying on conversions between function pointers and void *). -- Joseph S. Myers jos...@codesourcery.com