summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-04-29 16:37:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-04-29 16:37:25 -0300
commita901c505abffd13e96a7d304393bb759aad87e59 (patch)
treea15c9d6b4349c967202ce6244d580c70c3eddca5
parent0ddc0f47bd2a03678e1afbc384550aecb55a318f (diff)
downloadlua-github-a901c505abffd13e96a7d304393bb759aad87e59.tar.gz
Fixed warning about casts between function pointers
gcc now warns (with -Wextra) about casts between pointers to different function types. The type 'void(*)(void)' works as a 'void*' for function pointers, cleaning the warning.
-rw-r--r--loadlib.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/loadlib.c b/loadlib.c
index 9d86b158..ddfecca9 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -68,6 +68,13 @@ static const char *const CLIBS = "_CLIBS";
/*
+** Special type equivalent to '(void*)' for functions in gcc
+** (to supress warnings when converting function pointers)
+*/
+typedef void (*voidf)(void);
+
+
+/*
** system-dependent functions
*/
@@ -206,7 +213,7 @@ static void *lsys_load (lua_State *L, const char *path, int seeglb) {
static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) {
- lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym);
+ lua_CFunction f = (lua_CFunction)(voidf)GetProcAddress((HMODULE)lib, sym);
if (f == NULL) pusherror(L);
return f;
}