nrf: Add support for building C++ user modules.

The compiler flags -ansi -std=c11 were both being passed to g++, causing
weirdness. Removed the -ansi flag entirely, it's superseded by explicitly
setting the standard.

Also adds build coverage for user C modules (including C++) in CI.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2026-03-25 14:38:27 +11:00
committed by Damien George
parent 5ce74c3f7f
commit bc92f5a249
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -139,7 +139,7 @@ LDFLAGS += -Wl,--gc-sections
endif
CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
CFLAGS += $(INC) -Wall -Werror -ansi -std=c11 $(COPT) $(NRF_DEFINES) $(CFLAGS_EXTRA)
CFLAGS += $(INC) -Wall -Werror -std=c11 $(COPT) $(NRF_DEFINES) $(CFLAGS_EXTRA)
CFLAGS += -fno-strict-aliasing
CFLAGS += -I$(BOARD_DIR)
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
+1 -1
View File
@@ -39,7 +39,7 @@ endif
endif
# Add default C++ compiler flags based on CFLAGS. For use with C++ user modules.
CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99 -std=c99,$(CFLAGS) $(CXXFLAGS_MOD))
CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99 -std=c99 -std=c11,$(CFLAGS) $(CXXFLAGS_MOD))
# Add LDFLAGS to link libstdc++ on bare metal ports. Added only if a port has
# -nostdlib in LDFLAGS and C++ source files are provided.
+1 -1
View File
@@ -341,7 +341,7 @@ function ci_nrf_build {
make ${MAKEOPTS} -C mpy-cross
make ${MAKEOPTS} -C ports/nrf submodules
make ${MAKEOPTS} -C ports/nrf BOARD=PCA10040
make ${MAKEOPTS} -C ports/nrf BOARD=MICROBIT
make ${MAKEOPTS} -C ports/nrf BOARD=MICROBIT USER_C_MODULES=../../examples/usercmodule
make ${MAKEOPTS} -C ports/nrf BOARD=PCA10056 SD=s140
make ${MAKEOPTS} -C ports/nrf BOARD=PCA10090
}