Skip to main content
Jiannong Zhou
Associate III
April 16, 2023
Solved

Some code is not compiled with STM32CubeIDE

  • April 16, 2023
  • 2 replies
  • 1780 views

I am using STM32CubeIDE to develop a small project. But I do not know why some code  if(Motor_PullBack_Enable == 1) {} statement is not compiled.

 if(Motor_Extend_Enable == 1)

 {

....

 }

 if(Motor_PullBack_Enable == 1)

 {

...

}

 if(SPI_Receive_Buffer[2] != 0)

 {

}

Checked project.list file. there is no this if (){} statement.

 if(Motor_Extend_Enable == 1)

 8000632: 4b61    ldr r3, [pc, #388] ; (80007b8 <main+0x2e0>)

 8000634: 781b    ldrb r3, [r3, #0]

 8000636: 2b01    cmp r3, #1

 8000638: d136    bne.n 80006a8 <main+0x1d0>

 {

 }

  

  // there is no if(Motor_PullBack_Enable == 1)

    

 if(SPI_Receive_Buffer[2] != 0)

Please refer to attached source code. there is no compile error. Why not compile ?

Jiannong

This topic has been closed for replies.
Best answer by AScha.3

maybe the compiler/optimizer finds , this code will never be called - then it kicks it away.

+ example:

if((Movement_distance_pulse < 0) ...

but you set: uint32_t Movement_distance_pulse;

so it will never be negative...code can be removed, because if.. can never be true.

2 replies

AScha.3
AScha.3Best answer
Super User
April 16, 2023

maybe the compiler/optimizer finds , this code will never be called - then it kicks it away.

+ example:

if((Movement_distance_pulse < 0) ...

but you set: uint32_t Movement_distance_pulse;

so it will never be negative...code can be removed, because if.. can never be true.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Jiannong Zhou
Associate III
April 16, 2023

Hi AScha.3,

Yes. you are right. The code should be never implemented, it's removed.

After I re-code, the code can be seen in list file.

Thank you very much for your help!

Jiannong