Skip to content

Commit 964bb76

Browse files
committed
Fix some errors when compiling C++ code
After more or less recent changes, several headers do not compile when included by C++ code with default esp-idf SDK compiler flags. These issues were introduced by: - 320d476 (bitstring.h) - f260b37 (globalcontext.h) - 6816741 (intn.h) Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 9aa60f1 commit 964bb76

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/libAtomVM/bitstring.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ extern "C" {
7575
// these values are the same used from opcodes such as bs_get_utf16
7676
enum BitstringFlags
7777
{
78+
// Big endian & unsigned are the default
79+
BigEndianInteger = 0x0,
7880
LittleEndianInteger = 0x2,
7981
SignedInteger = 0x4,
8082
NativeEndianInteger = 0x10,
@@ -369,7 +371,7 @@ static inline bool bitstring_utf8_size(uint32_t c, size_t *out_size)
369371
* unicode character
370372
*/
371373
static inline bool bitstring_utf16_size(uint32_t c, size_t *out_size) {
372-
return bitstring_utf16_encode(c, NULL, 0, out_size);
374+
return bitstring_utf16_encode(c, NULL, BigEndianInteger, out_size);
373375
}
374376

375377
/**

src/libAtomVM/globalcontext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ static inline bool globalcontext_is_term_equal_to_atom_string(GlobalContext *glo
459459
*/
460460
static inline term globalcontext_make_atom(GlobalContext *glb, AtomString atom_string)
461461
{
462-
return globalcontext_insert_atom_maybe_copy(glb, atom_string_data(atom_string), atom_string_len(atom_string), false);
462+
return globalcontext_insert_atom_maybe_copy(glb, (const uint8_t *) atom_string_data(atom_string), atom_string_len(atom_string), false);
463463
}
464464

465465
/**

src/libAtomVM/intn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ size_t intn_sub_int64(int64_t num1, int64_t num2, intn_digit_t *out, intn_intege
405405
*/
406406
static inline intn_integer_sign_t intn_muldiv_sign(intn_integer_sign_t s1, intn_integer_sign_t s2)
407407
{
408-
return (intn_integer_sign_t) ((unsigned int) s1 ^ (unsigned int) s2) & IntNNegativeInteger;
408+
return (intn_integer_sign_t) (((unsigned int) s1 ^ (unsigned int) s2) & IntNNegativeInteger);
409409
}
410410

411411
/**

0 commit comments

Comments
 (0)