diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-02 11:09:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-02 11:09:46 -0300 |
commit | 781219dbe16fc327f5b828e1ff6fa45ec3265cba (patch) | |
tree | 2dfec8c7e051d41f436278df976ca2e5e0303704 /llimits.h | |
parent | d71fbc3175d3f1f9dff89edc3f04cd20447fe091 (diff) | |
download | lua-781219dbe16fc327f5b828e1ff6fa45ec3265cba.tar.gz lua-781219dbe16fc327f5b828e1ff6fa45ec3265cba.tar.bz2 lua-781219dbe16fc327f5b828e1ff6fa45ec3265cba.zip |
Small changes in casts from void* to functions
Macro moved to llimits.h, and casts from void* to lua_CFunction first
go through 'voidf' (a pointer to a function from void to void), a kind
of void* for functions.
Diffstat (limited to 'llimits.h')
-rw-r--r-- | llimits.h | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -153,6 +153,26 @@ typedef LUAI_UACINT l_uacInt; | |||
153 | 153 | ||
154 | 154 | ||
155 | /* | 155 | /* |
156 | ** Special type equivalent to '(void*)' for functions (to suppress some | ||
157 | ** warnings when converting function pointers) | ||
158 | */ | ||
159 | typedef void (*voidf)(void); | ||
160 | |||
161 | |||
162 | /* | ||
163 | ** Macro to convert pointer-to-void* to pointer-to-function. This cast | ||
164 | ** is undefined according to ISO C, but POSIX assumes that it works. | ||
165 | ** (The '__extension__' in gnu compilers is only to avoid warnings.) | ||
166 | */ | ||
167 | #if defined(__GNUC__) | ||
168 | #define cast_func(p) (__extension__ (voidf)(p)) | ||
169 | #else | ||
170 | #define cast_func(p) ((voidf)(p)) | ||
171 | #endif | ||
172 | |||
173 | |||
174 | |||
175 | /* | ||
156 | ** non-return type | 176 | ** non-return type |
157 | */ | 177 | */ |
158 | #if !defined(l_noret) | 178 | #if !defined(l_noret) |