Use standard static_assert instead of homemade macro

This commit is contained in:
wangqr 2020-05-09 12:15:07 -04:00
parent 38a0e20edc
commit 9d812a8aac
2 changed files with 5 additions and 20 deletions

View file

@ -4,6 +4,8 @@
* See copyright notice in luabins.h
*/
#include <assert.h>
#include "luaheaders.h"
#include "luabins.h"
@ -72,12 +74,9 @@ LUALIB_API int luaopen_luabins(lua_State * L)
* Consult PORTABILITY WARNING in saveload.h before changing constants.
*/
/* int is too small on your platform, fix LUABINS_LINT */
luabins_static_assert(sizeof(int) >= LUABINS_LINT);
/* size_t is too small on your platform, fix LUABINS_LSIZET */
luabins_static_assert(sizeof(size_t) >= LUABINS_LSIZET);
/* unexpected lua_Number size, fix LUABINS_LNUMBER */
luabins_static_assert(sizeof(lua_Number) == LUABINS_LNUMBER);
static_assert(sizeof(int) >= LUABINS_LINT, "int is too small on your platform, fix LUABINS_LINT");
static_assert(sizeof(size_t) >= LUABINS_LSIZET, "size_t is too small on your platform, fix LUABINS_LSIZET");
static_assert(sizeof(lua_Number) == LUABINS_LNUMBER, "unexpected lua_Number size, fix LUABINS_LNUMBER");
/*
* Register module

View file

@ -19,20 +19,6 @@
#define luabins_min3(a, b, c) \
( ((a) < (b)) ? luabins_min((a), (c)) : luabins_min((b), (c)) )
/* Preprocessor concatenation */
#define LUABINS_CAT(a, b) a##b
/* Static assert helper macro */
#define luabins_static_assert_line(pred, line) \
typedef char LUABINS_CAT( \
static_assertion_failed_at_line_, \
line \
)[2 * !!(pred) - 1]
/* Static (compile-time) assert */
#define luabins_static_assert(pred) \
luabins_static_assert_line(pred, __LINE__)
/* Internal error codes */
#define LUABINS_ESUCCESS (0)
#define LUABINS_EFAILURE (1)