How to enforce a coding standard in STMIDE ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-18 2: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.
- Labels:
-
DEBUG
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-18 4: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-18 4: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-18 2: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-19 5:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-22 8: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
