X-CUBE-AI 5.2.0 Validation: static declaration of 'MX_USART2_UART_Init' follows non-static declaration
With a fresh installation of STM32CubeIDE, after adding X-CUBE-AI 5.2.0 Validation template to a project, build fails with:
../Core/Src/main.c:55:13: error: static declaration of 'MX_USART2_UART_Init' follows non-static declarationHow to reproduce:
Create a new STM32 project.
In the board selector choose (for example) Nucleo-L476RE-P, validate project creation.
Add the X-CUBE-AI 5.2.0 software pack to the project with the Validation application template.
Set the Platform settings in the X-CUBE-AI configuration to the UART as needed.
Create a new network and import your model (TFLite used here).
Save and generate code.
Try to build project.
Actual behaviour:
Build fails with:
arm-none-eabi-gcc "../Core/Src/system_stm32l4xx.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DUSE_HAL_DRIVER -DSTM32L452xx -DDEBUG -c -I../Core/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -I../X-CUBE-AI/App -I../X-CUBE-AI -I../X-CUBE-AI/Target -I../Middlewares/ST/AI/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Core/Src/system_stm32l4xx.d" -MT"Core/Src/system_stm32l4xx.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/system_stm32l4xx.o"
../Core/Src/main.c:55:13: error: static declaration of 'MX_USART2_UART_Init' follows non-static declaration
static void MX_USART2_UART_Init(void);
^~~~~~~~~~~~~~~~~~~
In file included from ../Core/Src/main.c:21:0:
../Core/Inc/main.h:85:8: note: previous declaration of 'MX_USART2_UART_Init' was here
void MX_USART2_UART_Init(void);
^~~~~~~~~~~~~~~~~~~Indeed, `Core/Src/main.c` contains a forward declaration with the prototype:
static void MX_USART2_UART_Init(void);Then the definition with the prototype:
static void MX_USART2_UART_Init(void)While `Core/Inc/main.h` contains a declaration with the prototype:
void MX_USART2_UART_Init(void);`MX_USART2_UART_Init()` is called in `X-CUBE-AI/App/app_x-cube-ai.c` so it cannot be static in `Core/Src/main.c`.
Expected behaviour:
Project builds successfully.
`Core/Src/main.c` contains non-static prototype of `MX_USART2_UART_Init()` so that it can be called from `X-CUBE-AI/App/app_x-cube-ai.c`.
Temporary workaround:
After generating the code, you can remove the static forward declaration of `MX_USART2_UART_Init()` and remove the `static` keyword from its definition in `Core/Src/main.c`.
