lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2 January 2015 at 08:36, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
> We expect the compilation will go smoothly as usual
> but please report any warnings or other glitches.

Compiling with gcc's --pedantic gives a single warning:

loadlib.c: In function ‘lsys_sym’:
loadlib.c:151:21: warning: ISO C forbids conversion of object pointer
to function pointer type [-Wpedantic]
   lua_CFunction f = (lua_CFunction)dlsym(lib, sym);
                     ^

To get around this, you need to use this hack: (as seem in dlsym manpage/POSIX):

    double (*cosine)(double);

    /* 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");