?
Bashar schrieb:
Aufgrund der Ähnlichkeit zu dlsym (was sich auch im Namen niederschlägt) würde ich ganz stark davon ausgehen, dass sosym Zeiger auf beliebige Funktionstypen zurückliefern kann.
Nicht nur Zeiger auf Funktionen, sondern Adressen beliebiger Symbole. XSI verlangt daher, dass void* einen Funktionszeiger speichern kann.
dlsym - IEEE Std 1003.1-2004 schrieb:
RATIONALE
The ISO C standard does not require that pointers to functions can be cast back and forth to pointers to data. Indeed, the ISO C standard does not require that an object of type void * can hold a pointer to a function. Implementations supporting the XSI extension, however, do require that an object of type void * can hold a pointer to a function. The result of converting a pointer to a function into a pointer to another data type (except void is still undefined, however. Note that compilers conforming to the ISO C standard are required to generate a warning if a conversion from a void * pointer to a function pointer is attempted as in:
fptr = (int (*)(int))dlsym(handle, "my_function");
Due to the problem noted here, a future version may either add a new function to return function pointers, or the current interface may be deprecated in favor of two new functions: one that returns data pointers and the other that returns function pointers.
Klar ist das nicht unbedingt ideal. Ich bezweifle allerdings, dass die im letzten Absatz beschriebene mögliche Änderung in absehbarer Zeit realisiert wird. In der Tat sieht es sogar so aus, als sei der Absatz in neueren Versionen des Standards gestrichen worden.