I was using dlsym() to load a function symbol
void (*func)(int);
func = (func*)dlsym(phandle, "function");
This was resulting in compilation error. However, when I did typedef to function
typedef void (*func)(int);
func function = null;
function = (func*)dlsym(phandle, "function");
This compiled fine, but I fail to understand, why it was failing in first case? Could anyone please tell the reason? I read that C++ standard doesnt allow direct casting from void* to function pointer? Why is this and how did typedef solved this problem?