Skip to content

Conversation

@pguyot
Copy link
Collaborator

@pguyot pguyot commented Nov 9, 2025

The code currently doesn't compile with C++ source code with gcc and -fpermissive.

/__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/intn.h: In function 'intn_integer_sign_t intn_muldiv_sign(intn_integer_sign_t, intn_integer_sign_t)':
/__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/intn.h:408:74: error: invalid conversion from 'int' to 'intn_integer_sign_t' [-fpermissive]
  408 |     return (intn_integer_sign_t) ((unsigned int) s1 ^ (unsigned int) s2) & IntNNegativeInteger;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                                                                          |
      |                                                                          int
/__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/globalcontext.h: In function 'term globalcontext_make_atom(GlobalContext*, AtomString)':
/__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/globalcontext.h:462:70: error: invalid conversion from 'const void*' to 'const uint8_t*' {aka 'const unsigned char*'} [-fpermissive]
  462 |     return globalcontext_insert_atom_maybe_copy(glb, atom_string_data(atom_string), atom_string_len(atom_string), false);
      |                                                      ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
      |                                                                      |
      |                                                                      const void*
/__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/globalcontext.h:409:92: note:   initializing argument 2 of 'term globalcontext_insert_atom_maybe_copy(GlobalContext*, const uint8_t*, size_t, bool)'
  409 | static inline term globalcontext_insert_atom_maybe_copy(GlobalContext *glb, const uint8_t *atom_data, size_t atom_len, bool copy)
      |                                                                             ~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/jit.h:24,
                 from /__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/context.h:32,
                 from /__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/nifs.h:30,
                 from /__w/atomvm_m5/atomvm_m5/AtomVM/src/platforms/esp32/components/atomvm_m5/nifs/include/atomvm_m5.h:6:
/__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/bitstring.h: In function 'bool bitstring_utf16_size(uint32_t, size_t*)':
/__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/bitstring.h:372:44: error: invalid conversion from 'int' to 'BitstringFlags' [-fpermissive]
  372 |     return bitstring_utf16_encode(c, NULL, 0, out_size);
      |                                            ^
      |                                            |
      |                                            int
/__w/atomvm_m5/atomvm_m5/AtomVM/src/libAtomVM/bitstring.h:310:75: note:   initializing argument 3 of 'bool bitstring_utf16_encode(uint32_t, uint8_t*, BitstringFlags, size_t*)'
  310 | bool bitstring_utf16_encode(uint32_t c, uint8_t *buf, enum BitstringFlags bs_flags, size_t *out_size);
      |                                                       ~~~~~~~~~~~~~~~~~~~~^~~~~~~~

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@pguyot pguyot mentioned this pull request Nov 9, 2025
@pguyot pguyot changed the title Fix some warnings for newer compilers (idf-sdk 5.5) Fix some warnings for C++ compilation Nov 9, 2025
@pguyot pguyot changed the title Fix some warnings for C++ compilation Fix some errors when compiling C++ code Nov 9, 2025
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>
Copy link
Collaborator

@UncleGrumpy UncleGrumpy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me.

@bettio bettio merged commit 54d93a8 into atomvm:main Nov 10, 2025
190 of 195 checks passed
@pguyot pguyot deleted the w45/fix-warnings branch November 10, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants