TruePERSPECTIVES_logo.png

Improve your coding style using tools in the IDE [ECLIPSE on ARM]

Posted by Magnus Unemyr on May 21, 2015 11:05:23 AM

Many embedded developers write their code in a somewhat ad-hoc fashion, not really following a consistent coding style; either formally defined by the company or otherwise. Matters are even worse in multi-developer teams as every developer writes the code in their own style unless a coding style standard is enforced.

Code written in multiple inconsistent coding styles do not improve readability, understandability or maintainability of the code; embedded or not. This is why a C/C++ editor in embedded IDE’s should include tools to define what coding style you prefer, and also include features for auto-formatting. This helps improve the software quality and ease maintenance. This is how to do it.

format1

Atollic TrueSTUDIO and other ECLIPSE-based ARM Cortex IDE’s do this really well, as the C/C++ editor in ECLIPSE includes the tools needed to configure what coding style you want to enforce. You can choose one of the predefined coding styles (K&R, BSD/Allman, GNU or Whitesmiths) using a configuration dialog box:

format2

In Atollic TrueSTUDIO and other ECLIPSE IDE’s, you can easily define your own custom coding style too, using an IDE settings dialog box, containing tabs for different parts of the coding style:

  • Indentation
  • Braces
  • White space
  • New lines
  • Control statements
  • Line wrapping
  • Comments

With the one hundred or so configuration points available, you can define exactly how you want the code to be styled.

format3

For multi-user teams, it is even possible to export your custom defined coding style and import it into other instances of the IDE on other computers.

Using a consistent coding style in your own code, and across developers in a team, improves readability, understandability and maintenance, and in general is a step forward in improving your software quality.

What is your preferred coding style? Do you have any practical experiences (good or bad) related to coding style? Feel free to share your thoughts in the commenting section below!

If you want to read more on ECLIPSE-based compiler and debugger IDE tools for ARM Cortex (perhaps you develop for STM32, Kinetis, LPC or EFM32?), read this white paper:

Read our ARM development whitepaper!

 

 

%MCEPASTEBIN%