The code comes from this page: http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html
Can you help me understand this?
It takes the address of the function pointer, casts it to void** and then dereferences it. I don’t know why it has to work like this.
I appreciate your help! Until now, the only advice I have gotten was “read it from right to left” or something like “read it in cycles from right to left”.
The meaning of the code is:
fptr. The type of this expression is pointer-to-pointer-to-function (of some specific type).fptras if it were an object of typevoid *.Unfortunately, whoever wrote this example in POSIX was on crack, because step 3 violates the aliasing rules of the C language and thus invokes undefined behavior. In particular, real-world compilers will optimize this code in ways that breaks the intended usage.
What the author of this example was trying to achieve was avoiding casting the right-hand side from pointer to void to pointer to function. This is based on a claim that the C standard requires this cast to generate a warning, but I have searched thoroughly for such a requirement and can find no such requirement.
If such a problem really does exist (the warning requirement), then the only way to silence the warning without invoking undefined behavior (like the bad example in the text of POSIX) is to do this: