Skip to main content
JulienD
Associate III
Dec 6, 2018 1:02 PM UTC
Question

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

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

This topic has been closed for replies.

2 replies

Khouloud GARSI
ST Employee
Dec 7, 2018 1:28 PM UTC

Hi @Julien D_Oevillers​ ,

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

Khouloud.

Nawres GHARBI
ST Technical Moderator
Dec 7, 2018 2:58 PM UTC

Hi @Julien D_Oevillers​ 

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