Background
The POSIX standard adds a lot of library functions and other identifiers to the C language. In the description of the dlsym()
function, it says (with my emphasis):
SYNOPSIS
#include <dlfcn.h> void *dlsym(void *restrict handle, const char *restrict name);
DESCRIPTION
The dlsym() function shall obtain the address of a symbol (a function identifier or a data object identifier) ...
The C standard doesn't guarantee that a function pointer can be converted to a void *
, or even that the size of the pointers are the same. This effectively adds an additional restriction on C's type system.
Question
My question is this:
- Is there a normative reference for this restriction of C's type system, or is it only deducible from the description of certain library functions?
- Is POSIX even implementable on a system where
sizeof (function pointer) > sizeof (void *)
?
References
- The C11 Standard (final public draft): n1570
- The POSIX Standard from The Open Group: POSIX.1-2008
- The POSIX
dlsym()
function
The dlsym() reference says the conversion is not defined by the C standard but that a conforming implementation has to make this work correctly. So on systems where this can not be made to work would not be a conforming implementation and would presumably document this:
there is an old article that talks about this from the C++ perspective and links to an older version of the dlsym() reference and has a more detailed explanation: