cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMx bug ? Code generated does not link with c++

JulienD
Senior

Hello

An F4 project with a timer in output compare mode generates in main.c a call to   HAL_TIM_MspPostInit(&htim1);

This function is implemented in stm32f4xx_hal_msp.c but is declared in main.c file.

If I change main.c to main.cpp. It does not link.

My opinion is that CubeMx should generate a stm32f4xx_hal_msp.h file containing the public functions declarations within an extern "C". Something like this :

#ifndef STM32F4XX_HAL_MSP_H_
#define STM32F4XX_HAL_MSP_H_
 
 
#ifdef __cplusplus
extern "C" {
#endif
 
void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim);
 
#ifdef __cplusplus
}
#endif
 
 
#endif /* STM32F4XX_HAL_MSP_H_ */

The main.c file should include it.

My 2 cents.

Julien

2 REPLIES 2
Khouloud GARSI
Lead II

Hi @Julien D_Oevillers​ ,

Your feedback is forwarded internally. We will answer you ASAP.

Khouloud.

Nawres GHARBI
ST Employee

Hi @Julien D_Oevillers​ 

Thanks for the Feedback, we will take your request into consideration in a next release