cancel
Showing results for 
Search instead for 
Did you mean: 

How to enforce a coding standard in STMIDE ?

DJC
Senior

Is there a way to enforce a coding standard in STMIDE with some text highlighting?

i.e: "function names should be Function_Name()" etc.

What rules does STM use for their generated libraries in this case?

Does anyone recommend some plugins for this? 

What standards are others trying to follow when writing their code?

1 ACCEPTED SOLUTION

Accepted Solutions
Ozone
Lead II

"Coding standards" are totally arbitrary.

You can enforce rules like MISRA through integrating PCLint (or similar tools).

Otherwise, you can do code reviews.

View solution in original post

5 REPLIES 5
Ozone
Lead II

"Coding standards" are totally arbitrary.

You can enforce rules like MISRA through integrating PCLint (or similar tools).

Otherwise, you can do code reviews.

TDK
Guru

There is no standard for enforcing coding standard in C or C++, partly because the language is 30+ years old and existing code out there.

Eclipse (which STM32CubeIDE is build from) can auto-format things. I find that helps quite a bit when importing messy/outside code.

Window -> Preferences -> C/C++ -> Code Style -> Formatter

Auto-formatting can be done with Source -> Format.

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

Handy! Thanks!

Based on this, it looks like the Code Gen is done with the formatter set to GNU. However when one installs STMIDE, the formatter is set to K&R by default.

Not a big deal, but I do bet a bunch of people get a bit OCD when they press tab in main.c and it tabs out to a different place that what is already written.

Based on the code pasted into the forum by users, I would be surprised if more than 20% of programmers enforced any type of style at all.
If you feel a post has answered your question, please click "Accept as Solution".

:face_with_tears_of_joy: i hear ya !

I think it would benefit the community if ST packaged some PClint or similar as an easy opt-in