2020-11-18 02:37 AM
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?
Solved! Go to Solution.
2020-11-18 04:37 AM
"Coding standards" are totally arbitrary.
You can enforce rules like MISRA through integrating PCLint (or similar tools).
Otherwise, you can do code reviews.
2020-11-18 04:37 AM
"Coding standards" are totally arbitrary.
You can enforce rules like MISRA through integrating PCLint (or similar tools).
Otherwise, you can do code reviews.
2020-11-18 02:53 PM
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.
2020-11-19 12:41 AM
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.
2020-11-19 05:48 AM
2020-11-22 08:54 AM
: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