cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE while(1) bug? Linux versions

xisco
Associate III

Hello,

 

I see in code generated by all Linux versions of CubeIDE that USER CODE BEGIN and USER CODE END tags in infinite loop, are not in the better place.

Code generated by Cude IDE:

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

The USER CODE BEGIN WHILE is outside the loop, and the USER CODE BEGIN 3 is into the loop.

I think it would be better, especially for beginner programmers, something like this:

  /* Infinite loop */
  while (1)
  {
    /* USER CODE BEGIN WHILE */

    /* USER CODE END WHILE */
  }
  /* USER CODE BEGIN 3 */

  /* USER CODE END 3 */

Or is there some reason to generate the code like the above?

 

Greetings

1 ACCEPTED SOLUTION

Accepted Solutions

As the others have said, this has nothing to do with Linux - it's the same on other platforms.

 


@xisco wrote:

USER CODE BEGIN and USER CODE END tags in infinite loop, are not in the better place.


They are in a perfectly reasonable place.

 


@xisco wrote:

is there some reason to generate the code like the above?


Yes: The current method lets the user choose whether to have a while(1) loop, or a for(;;) loop - or any other structure they prefer.

View solution in original post

3 REPLIES 3
SofLit
ST Employee

Hello,

It's not a limitation on Linux version, it's also implemented on other platforms: windows and MACOS. Also, there is no sense to put CODE 3 just after while(1) as it's not reachable:

  /* Infinite loop */
  while (1)
  {
    /* USER CODE BEGIN WHILE */

    /* USER CODE END WHILE */
  }
  /* USER CODE BEGIN 3 */

  /* USER CODE END 3 */

  

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
STea
ST Employee

Hello @xisco ,

this is not only specific to CubeIDE versions on Linux it is across all platforms and the reason for that is the code generation feature of cubeMX which keeps all written code in those delimiters when regenerating the code so we wouldn't lose the while loop or the conditions that could be modified.
Regards

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

As the others have said, this has nothing to do with Linux - it's the same on other platforms.

 


@xisco wrote:

USER CODE BEGIN and USER CODE END tags in infinite loop, are not in the better place.


They are in a perfectly reasonable place.

 


@xisco wrote:

is there some reason to generate the code like the above?


Yes: The current method lets the user choose whether to have a while(1) loop, or a for(;;) loop - or any other structure they prefer.