Explorar o código

BUG: Cannot cast Lua function pointer in standard C

src/civetweb.c:5533:0:
src/mod_lua.inl: In function ‘mg_exec_lua_script’:
src/mod_lua.inl:1169:37: error: ISO C forbids conversion of object
  pointer to function pointer type [-Wpedantic]
      lua_pushcclosure(L, (lua_CFunction) exports[i + 1], 0);
                              ^

This patch uses the POSIX.1-2003 workaround.
See linux.die.net/man/3/dlsym
Matt Clarkson %!s(int64=10) %!d(string=hai) anos
pai
achega
260f8a43b9
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      src/mod_lua.inl

+ 3 - 1
src/mod_lua.inl

@@ -1162,7 +1162,9 @@ void mg_exec_lua_script(struct mg_connection *conn, const char *path,
             lua_pushglobaltable(L);
             for (i = 0; exports[i] != NULL && exports[i + 1] != NULL; i += 2) {
                 lua_pushstring(L, (const char *)(exports[i]));
-                lua_pushcclosure(L, (lua_CFunction) exports[i + 1], 0);
+                lua_CFunction func;
+                *(const void**)(&func) = exports[i + 1];
+                lua_pushcclosure(L, func, 0);
                 lua_rawset(L, -3);
             }
         }