0

I'm starting a decently sized project around arduino/ATMELavr, and I came to wonder if there are any commonly accepted C/C++ coding standards or style guidelines specifically aimed at embedded C++/arduino.

I've worked mostly with python recently, and came to love the PEP8 guidelines, and the associated pep tool (which checks syntax consistency with the style guide). Similarly, I've used jslint and similar tools for javascript, as I find they help keeping your code base homogeneous, and avoid wasting time and commits on silly typos, and arguing over where the braces should go.

Any similar tools for C++ or more specifically arduino C++?

  • There is no such thing as "Arduino C++"; the magic is in the IDE, not the language. Also, you may want to try Programmers.SE for a style guide. – Ignacio Vazquez-Abrams Jan 9 '15 at 16:50
0

In my experience (15 years in industry, 30 total), this does not matter. What matters is having good developers who understand code written in ANY valid style. I currently work at a large bank, and there's 2 different bracket styles being used in our code, and nobody cares. Good developers don't care about this. We care a lot more about the code being valid, error-free, and efficient. If you do that, I don't care where your brackets are.

Yes, there are style guides for C++ but you don't need to use them. This is a good one though...

http://google-styleguide.googlecode.com/svn/trunk/cppguide.html

I am not aware of any style tools that integrate into Arduino IDE. There are some style tools that integrate into Eclipse though - and if this is important to you and your team, I strongly suggest using Eclipse for development. The Arduino IDE isn't really for large projects.

http://astyleclipse.sourceforge.net/ - but Eclipse doesn't really need this, it has a pretty good built-in formatter.

  • I don't intend to use the arduino IDE, it is pretty useless indeed beyond quickly testing some simple code. But I'm not a big fan of eclipse either, which I find clunky. The plugin you mention is built on top of astyle.sourceforge.net. There may be a way to use it as a validator rather than formatter. – Laurent S Jan 10 '15 at 17:34
  • Actually the Arduino IDE uses AStyle. In folder IDE/lib there's file formatter.conf file that you can edit if the default style doesn't suffice or fit – Federico Fissore Jan 11 '15 at 18:56
  • @Jasmine the google coding style is pretty much what I was looking for. google-styleguide.googlecode.com/svn/trunk/cpplint has the sort of tool I was looking for. Thanks for putting me on the right path! – Laurent S Jan 11 '15 at 23:00
  • Just as long as you remember that attempting to enforce a style will hurt you a lot more than it will help you. I hope I made that point clear. People with less experience will debate that, because they haven't witnessed the damage it can cause. – Jasmine Jan 12 '15 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.