diff options
| author | dearblue <[email protected]> | 2021-10-24 23:11:52 +0900 |
|---|---|---|
| committer | dearblue <[email protected]> | 2021-10-24 23:11:52 +0900 |
| commit | b774832ee1a97c44cabbbaac004a3b784ed02a83 (patch) | |
| tree | 28e1cf6551e42b933d6a2fbeff1dce4970106e34 /src/hash.c | |
| parent | 7850549a5edf2952056234203d2c72cf264f08eb (diff) | |
| download | mruby-b774832ee1a97c44cabbbaac004a3b784ed02a83.tar.gz mruby-b774832ee1a97c44cabbbaac004a3b784ed02a83.zip | |
Make `mrb_static_assert()` a variable argument
`mrb_static_assert()` extends the macro function to take one or two arguments.
If the argument is other than that, an error will occur.
References:
- static_assert のメッセージ省略を許可 - cpprefjp C++日本語リファレンス
https://cpprefjp.github.io/lang/cpp17/extending_static_assert.html
- c - Overloading Macro on Number of Arguments - Stack Overflow
https://stackoverflow.com/a/11763277
Diffstat (limited to 'src/hash.c')
| -rw-r--r-- | src/hash.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/hash.c b/src/hash.c index a12e45bd7..c0d3d712f 100644 --- a/src/hash.c +++ b/src/hash.c @@ -69,8 +69,8 @@ #define AR_MAX_SIZE 16 #define H_MAX_SIZE EA_MAX_CAPA -mrb_static_assert1(offsetof(struct RHash, iv) == offsetof(struct RObject, iv)); -mrb_static_assert1(AR_MAX_SIZE < (1 << MRB_HASH_AR_EA_CAPA_BIT)); +mrb_static_assert(offsetof(struct RHash, iv) == offsetof(struct RObject, iv)); +mrb_static_assert(AR_MAX_SIZE < (1 << MRB_HASH_AR_EA_CAPA_BIT)); typedef struct hash_entry { mrb_value key; @@ -243,7 +243,7 @@ DEFINE_SWITCHER(ht, HT) * assumptions. */ # define HT_ASSERT_SAFE_READ(attr_name) \ - mrb_static_assert1( \ + mrb_static_assert( \ offsetof(hash_table, attr_name) + sizeof(((hash_table*)0)->attr_name) <= \ sizeof(hash_entry)) HT_ASSERT_SAFE_READ(ea); |
