<div dir="ltr"><div><div><div><div>As a consultant I see a lot of different coding styles. Every different group seems to have a preferred coding styles and thinks theirs is best.<br><br></div>IMHO coding style is about the least important thing about code. What is more important is that it is easy to read and you can make a dog's breakfast of any coding style.<br><br></div>Coding style is just something relatively trivial that is easy to argue about and get outraged about. The more important things like design are very much more abstract than coding style and are harder to quantify.<br><br></div>I use code-style insistence as a weathervane: the more people get uptight about coding style, the less they understand about real code quality.<br><br></div>Get hold of GNU-indent and run your code through that with different options until one strikes your fancy.<br><div><div><div><div><div><br></div><div>-- Charles<br></div><div><div><div><div><div><div><br><br></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 22, 2016 at 12:04 AM, Volker Kuhlmann <span dir="ltr"><<a href="mailto:list0570@paradise.net.nz" target="_blank">list0570@paradise.net.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed 21 Sep 2016 22:47:06 NZST +1200, Richard Jones wrote:<br>
<br>
> Offers anyone?<br>
<br>
There are as many opinions as there are C programmers...<br>
The main thing is to be consistent. Beyond that, take your personal<br>
pick. I always tell people if they expect the rest of the world to<br>
format to their personal preference they're going to be onto a loser,<br>
like when they have to read other peoples' code.<br>
<br>
By and large I like the Linux kernel style, it's verbose enough to be<br>
legible and doesn't waste screen real estate. Some people get hyper on<br>
this:<br>
  if (something == 45)<br>
  {<br>
    for (i = ...)<br>
    {<br>
      a += 5;<br>
    }<br>
  }<br>
  else<br>
  {<br>
    do something else;<br>
  }<br>
I find it idiotic. Lots of space for not doing much. The more of the<br>
code I can see at once the less time I have to flick around.<br>
<br>
The arduino one looks OK at a glance, but contains some nonsense too.<br>
<br>
If you want to get really serious, check what Jack Ganssle has to say<br>
about it.<br>
<br>
More practically speaking, I'd say stick to something you have a source<br>
formatter for, so you can reformat, fix up, and enforce. Basically there<br>
is astyle (command line and library), which offers a number of options,<br>
all with their tuning. It can be a little confusing because there's a<br>
difference between what it'll tolerate and what it'll forcefully change,<br>
and I found it not totally elaborate enough in some cases. It's<br>
integrated into codeblocks, a general purpose IDE that supports AVR (all<br>
FOSS). Worth a look, but I found the editor still sucks too much. The<br>
style formatter it good though (within astyle's limits). No reason to<br>
only use one editor for a project. I find all suck, just in different<br>
ways.<br>
<br>
The best formatter is in eclipse. The interface looks a bit like astyle<br>
but it must have its own.<br>
<br>
If there are other (Linux, not interested in MS whatsit studio)<br>
formatters I'd like to hear.<br>
<br>
HTH,<br>
<br>
Volker<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Volker Kuhlmann<br>
<a href="http://volker.top.geek.nz/" rel="noreferrer" target="_blank">http://volker.top.geek.nz/</a>      Please do not CC list postings to me.<br>
<br>
______________________________<wbr>_________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.<wbr>co.nz</a><br>
<a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">http://lists.ourshack.com/<wbr>mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/<wbr>pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.<br>
</font></span></blockquote></div><br></div>