Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Use standard static_assert instead of homemade macro
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqr committed May 9, 2020
1 parent 605caee commit a57fda0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
11 changes: 5 additions & 6 deletions vendor/luabins/src/luabins.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* See copyright notice in luabins.h
*/

#include <assert.h>

#include "luaheaders.h"

#include "luabins.h"
Expand Down Expand Up @@ -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
Expand Down
14 changes: 0 additions & 14 deletions vendor/luabins/src/saveload.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a57fda0

Please sign in to comment.