blt4linux / blt4l

PAYDAY 2 SteamOS/Linux LUA loader.
Other
57 stars 14 forks source link

Macros: Fix undefined behavior when casting from void * to func-ptrs #6

Closed ljrk0 closed 8 years ago

ljrk0 commented 8 years ago

This fixes the undefined behavior which GCC warns about. as casting a void * to a function pointer is undefined in C99:

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().

source: man 3 dlsym