diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-04-29 16:37:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-04-29 16:37:25 -0300 |
commit | a901c505abffd13e96a7d304393bb759aad87e59 (patch) | |
tree | a15c9d6b4349c967202ce6244d580c70c3eddca5 /loadlib.c | |
parent | 0ddc0f47bd2a03678e1afbc384550aecb55a318f (diff) | |
download | lua-a901c505abffd13e96a7d304393bb759aad87e59.tar.gz lua-a901c505abffd13e96a7d304393bb759aad87e59.tar.bz2 lua-a901c505abffd13e96a7d304393bb759aad87e59.zip |
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.
Diffstat (limited to 'loadlib.c')
-rw-r--r-- | loadlib.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -68,6 +68,13 @@ static const char *const CLIBS = "_CLIBS"; | |||
68 | 68 | ||
69 | 69 | ||
70 | /* | 70 | /* |
71 | ** Special type equivalent to '(void*)' for functions in gcc | ||
72 | ** (to supress warnings when converting function pointers) | ||
73 | */ | ||
74 | typedef void (*voidf)(void); | ||
75 | |||
76 | |||
77 | /* | ||
71 | ** system-dependent functions | 78 | ** system-dependent functions |
72 | */ | 79 | */ |
73 | 80 | ||
@@ -206,7 +213,7 @@ static void *lsys_load (lua_State *L, const char *path, int seeglb) { | |||
206 | 213 | ||
207 | 214 | ||
208 | static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { | 215 | static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { |
209 | lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym); | 216 | lua_CFunction f = (lua_CFunction)(voidf)GetProcAddress((HMODULE)lib, sym); |
210 | if (f == NULL) pusherror(L); | 217 | if (f == NULL) pusherror(L); |
211 | return f; | 218 | return f; |
212 | } | 219 | } |