cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX Source code format

blechleitner
Associate II
Posted on November 15, 2015 at 16:31

Hi,

when CubeMX generates code, it is intended by 2 spaces. Ist there the possibility to change this behaviour to get a tab character instead. I searched in the forum and googled for a while but unfortunately, I didn't find any solution for that. I should have this due to some company policies.

And, please, do not open a new scene in the holy war about tabs/spaces. I know this quite well and there are (dis)advantages for both versions. It's just, I'm bound to the tab side... ;)

Thanks in advance!

Have a nice day,

Bernhard
1 ACCEPTED SOLUTION

Accepted Solutions
Sirma Siang
ST Employee
Posted on October 13, 2017 at 11:31

For this very old thread,

I would recommend to use an external tool (astyle) which is available for all platforms (Win, Linux and MacOS). It allows to format the source code in a very flexible way. It is intensively used at Linux Kernel side. It is available from

github:

https://github.com/llamasoft/sgminer-kernels

Kind regards

Sirma

View solution in original post

4 REPLIES 4
Posted on November 16, 2015 at 01:28

Somehow I suspect your request is going to be difficult to apply universally, and with rigour. ie require far too much effort.

I should have this due to some company policies... It's just, I'm bound to the tab side..

Then presumably an issue you've addressed before, multiple times, around here we have custom tools that get it done in a way the formatting deities instruct.

See also

http://uncrustify.sourceforge.net/

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on November 16, 2015 at 23:12

Move all of Cube's generated code into a directory called hal.

Rename their main.c to stcubeinit.c or whatever your style guidelines permits.

Rename ST's main() to something like STCubeInit() and comment out their infinite loop. 

Declare this code gospel and it must never be messed with outside of cube, except perhaps assert_failed().

Create your own main.c and main() that calls STCubeInit().

Treat the cube code as a code library and don't put your code in the user sections at all.

Carry on.
stm32cube-t
Senior III
Posted on January 15, 2016 at 17:37

Dear user,

We have logged your enhancement request but do not have a plan yet for its delivery.

Sorry for the inconvenience.

Best regards
Sirma Siang
ST Employee
Posted on October 13, 2017 at 11:31

For this very old thread,

I would recommend to use an external tool (astyle) which is available for all platforms (Win, Linux and MacOS). It allows to format the source code in a very flexible way. It is intensively used at Linux Kernel side. It is available from

github:

https://github.com/llamasoft/sgminer-kernels

Kind regards

Sirma