[Xastir-dev] Proposal to change project coding standards: Please vote!

Curt Mills curt.we7u at gmail.com
Wed May 1 08:32:51 PDT 2019


We've been talking in another thread about changing the project coding
standards, specifically the number of columns to indent and the bracing
standard.

Our two relevant Wiki pages are:
http://xastir.org/index.php/HowTo:Contributing
and
http://xastir.org/index.php/HowTo:Developer_Guidelines_and_Notes


1) Indents: I originally proposed that we go from 4-column indents to
2-character indents (Spaces-only, no tab characters unless required for a
specific tool). I'm going to back-peddle after reading a bunch of stuff on
the 'net: People say 4-char indent for C and C++ makes it more readable.

***** Please vote on number of chars per indent. *****


2) Bracing alignment: I prefer lining up the braces vertically which I find
shows the structure of the code much better.

We currently use:

    if (true) {
        do something;
    else {
        do something else;
    }

I'm proposing:

    if (true)
    {
        do something;
    }
    else
    {
        do something else;
    }

***** Please vote whether to line up the braces. *****


3) Optional bracing: I prefer to include braces when they're optional to
improve readability. An example case: An "if" statement with one statement
in the "true" block can be written as:

    if (true)
        do something;

-or-

    if (true)
    {
      do something;
    }

I prefer the latter. It's not always immediately obvious what you're doing
without the braces, particularly when there isn't an "else" clause and/or
indenting gets messed up.

***** Please vote whether to include braces when optional. *****


4) One new thing we need (At least with newer compilers) is a comment where
a case statement drops through to the next case statement. This example is
from db.c:

            case 'O':
                symbol.aprs_type = '\\';
                /* Falls through. */

            case 'B':

Without that "Falls through" comment we get a compiler warning, so please
add that from now on. This item does not require a vote. I already fixed
the sources where we needed it.

We could specify a whole bunch of other stuff but the rest isn't all that
important.

My votes:
1) 4-char spaces-only
2) Line up braces vertically
3) Include braces when optional

-- 
Curt, WE7U        http://we7u.wetnet.net        http://www.sarguydigital.com


More information about the Xastir-dev mailing list