Undefined reference error in STM32CubeIDE by mixing C and C++ code

07/11/2024

Just a reminder on how to mix C and C++ code in STM32CubeIDE

This page exists just to remind myself that this is a possible issue and it has nothing to do with linker flags or source files not getting compiled.

Remember to wrap your C files with:

#ifdef __cplusplus
extern "C" {
#endif

// C code here

#ifdef __cplusplus
}
#endif

(or #includes in C++ files) with:

extern "C"{
	// #include "header.h"
}
All posts
davespace.xyz – 2024