Skip to content

Commit 891350b

Browse files
committed
Do not use _Static_assert in headers
_Static_assert is not compatible with C++, that uses static_assert instead. Signed-off-by: Davide Bettio <davide@uninstall.it>
1 parent 10ce113 commit 891350b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/libAtomVM/term.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@
3737
#include <stdint.h>
3838
#include <stdio.h>
3939

40+
// intn doesn't depend on term
41+
_Static_assert(
42+
(int) TermPositiveInteger == (int) IntNPositiveInteger, "term/intn definition mismatch");
43+
_Static_assert(
44+
(int) TermNegativeInteger == (int) IntNNegativeInteger, "term/intn definition mismatch");
45+
46+
// Make sure avm_int_t can always fit into size_t
47+
_Static_assert(SIZE_MAX >= AVM_INT_MAX, "SIZE_MAX < AVM_INT_MAX is an unsupported configuration.");
48+
4049
enum TermTypeIndex {
4150
TERM_TYPE_INDEX_INVALID = 0,
4251
TERM_TYPE_INDEX_INTEGER = 1,

src/libAtomVM/term.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,12 +1476,6 @@ static inline bool term_is_bigint(term t)
14761476
&& (term_boxed_size(t) > (INTN_INT64_LEN * sizeof(intn_digit_t)) / sizeof(term));
14771477
}
14781478

1479-
// intn doesn't depend on term
1480-
_Static_assert(
1481-
(int) TermPositiveInteger == (int) IntNPositiveInteger, "term/intn definition mismatch");
1482-
_Static_assert(
1483-
(int) TermNegativeInteger == (int) IntNNegativeInteger, "term/intn definition mismatch");
1484-
14851479
/**
14861480
* @brief Extract multi-precision integer data from boxed term
14871481
*

src/libAtomVM/term_typedef.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ typedef uint64_t avm_uint64_t;
8686
#error "term size must be either 32 bit or 64 bit."
8787
#endif
8888

89-
_Static_assert(SIZE_MAX >= AVM_INT_MAX, "SIZE_MAX < AVM_INT_MAX is an unsupported configuration.");
90-
9189
#define UNICODE_CHAR_MAX 0x10FFFF
9290

9391
#define MIN_NOT_BOXED_INT (AVM_INT_MIN >> 4)

0 commit comments

Comments
 (0)