Skip to main content
dieter 123
Associate III
October 22, 2021
Solved

CUBE IDE and code style checker

  • October 22, 2021
  • 4 replies
  • 10392 views

Hi folks,

STM32CubeIde /eclipse comes with a code style checker. I just ran it. The default settings do not cover ST's code style. Is it possible to get a config file so CubeIde automatically checks for STM32s coding guidelines?

Is ST development team using any code style checker?

Thanks

This topic has been closed for replies.
Best answer by Pavel A.

If it isn't too hard, could you provide a formatter xml for "ST HAL" style and make it selectable from Preferences? Indeed this will save hassle for new users.

4 replies

dieter 123
Associate III
October 25, 2021

Hi

@Erwan LE-SAINT​ @Imen DAHMEN​ 

can one of you comment on this?

Erwan LE-SAINT
ST Technical Moderator
October 25, 2021

Hello, after checking with IDE developers, no change of setup from Eclipse preferences from CubeIDE.

Regards,

mattias norlander
ST Employee
October 27, 2021

Hi @dieter 123​,

The code style/formatting supported by CubeIDE is provided as-is from Eclipse/CDT. This means you can select between a number of different styles, you can see the options in this menu: Window > Preferences > C/C++ > Code Style > Formatter

  • K&R
  • BSD/Allman
  • GNU
  • Whitesmiths

None of these are however used internally at ST when developing the STM32Cube packages. This has legacy reasons. The Cube packages are instead closer to ANSI. Not sure which one is closest to ANSI, possibly BSD/Allman. But indentation is not correct. This can however be modifed in:

Window > Preferences > C/C++ > Code Style > Formatter > BSD/Allman > Edit > Indentation.

The formatting will however not be identical. It may be possible to setup an identical profile in Eclipse. Nothing I have tried.

It may also be possible to rely on an external tool to achieve this.

Yuan1
Associate II
October 27, 2021

This would be a very useful feature.

Pavel A.
Pavel A.Best answer
October 28, 2021

If it isn't too hard, could you provide a formatter xml for "ST HAL" style and make it selectable from Preferences? Indeed this will save hassle for new users.