While using the MCU plus SDK in a C++ project, i noticed that some header file have broken C linkage guards. The affected headers use #ifdef _cplusplus instead of #ifdef __cplusplus. So all that is missing is an exctra leading underscore (_).
Since _cplusplus is not defined, extern "C" {...} is missing and thus linking from C++ to the C objects fails.
Bellow a snippet which shows the pattern.
#ifdef _cplusplus // <- needs to be __cplusplus
extern "C" {
#endif
// C code
#ifdef _cplusplus // <- needs to be __cplusplus
}
#endif
I found the issue in the following header files:
- mcu_plus_sdk_am263px_11_00_00_19/source/sdl/ecc_bus_safety/v0/sdl_ecc_bus_safety.h
- mcu_plus_sdk_am263px_11_00_00_19/source/sdl/ecc_bus_safety/v0/soc/am263px/sdl_ecc_bus_safety_soc.h
- mcu_plus_sdk_am263px_11_00_00_19/source/sdl/mcrc/v0/sdl_mcrc.h
- mcu_plus_sdk_am263px_11_00_00_19/source/sdl/mcrc/v0/soc/am263px/sdl_mcrc_soc.h
For now, I just include the affected headers in my own extern "C" { ... } code block.
Kind regards
Tobias Jäggi
I used
- C++ 17
- AM263Px control card
- MCU+ SDK for AM263Px 11.0.0.19