KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Possible Duplicate: Why are function pointers and data pointers incompatible in C/C++? In the man page for dlsym, the following snippet has been provided. double (*cosine)(double); handle = dlopen("libm.so", RTLD_LAZY); /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos"); would seem more natural, but the C99 standard leaves casting from "void *" to a function pointer undefined. The assignment used below is the POSIX.1-2003 (Technical Corrigendum 1) workaround; see the Rationale for the POSIX specification of dlsym(). */ *(void **) (&cosine) = dlsym(handle, "cos"); I looked up the relevant spec page , but still cannot grasp the reason behind not allowing conversions from void pointers to function pointers. Aren't void pointers supposed to be big enough to accomodate all types of pointers. If so, why leave this casting undefined?
Tags (comma-separated)
Save Edits
Cancel