cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMx Code generation duplicating lines in main.c

rasem
Associate II

Hi. I am using NUCLE-F439ZI board

STM32CubeIDE Version: 1.16.0
Build: 21983_20240628_1741 (UTC)

Lately I am experiencing problem, when I make changes in .IOC file and save and generate code

it is messing my main.c file. It is copying big portion of main.c lines and adding them again in main.c file.

It is impossible to continue working. Is this a setting problem or a bug in the software?

Please help.

Thank you.

Rasem

11 REPLIES 11

This really shouldn't be this difficult.

> I am attaching good main.c which builds without errors.

The main.c file you have attached contains many "/* USER CODE" texts within USER CODE blocks.

TDK_0-1725329258903.png

It also includes several duplicate definitions, including two of main() where the first one is unfinished. It definitely does not compile.

TDK_1-1725329579039.png

Perhaps edit your file so "USER CODE" is not used anywhere within the user code sections.

When I edit your file to correct the above errors, it compiles. If I edit the IOC and regenerate code, it does not duplicate sections.

If you feel a post has answered your question, please click "Accept as Solution".
rasem
Associate II

Thank you TDK. Perfect solution. Everything is fine now.