Verified Commit 9ab22dbc authored by Thomas Haller's avatar Thomas Haller
Browse files

CONTRIBUTING: clarify on the use/lack of curly braces around blocks

This is the style we have ever since. Spell it out. With the difference
that now single line statements may have braces.

Recently we were already sloppy about allowing curly braces for single line
statements. Maybe there was a point in that. Imagine you start with:

    if (condition)
        call(some, parameter);

Afterwards you change the code so that the line becomes too long and
clang-format wraps the line (requiring you to add braces):

    if (condition) {

The problem now is that this diff is larger than it would have been, if
you added curly braces from the start. Also, it means you have to go
back and forth to add/remove these braces, as clang-format reformats the

Also, if you have if-else-if blocks, then mixing multi line statements
with single line statements is also cumbersome, because when something
needs to change, the diff is may be larger (and the change more

So it might be convenient to just always add the braces, and the
documented style now allows for that.
parent d5f917e7
Pipeline #481391 canceled with stages
......@@ -101,6 +101,9 @@ some details of the style we use:
- GOOD: `#define MY_CONSTANT 42`
- BAD: `static const unsigned myConstant = 42;`
* Always use curly braces for blocks that span multiple lines. For single lines
the braces may be omitted, but are not prohibited.
Additionally, we require to build without compiler warnings for the warnings
that we enable. Also, our language is C11 with some GCC-isms (like typeof(),
expression statements, cleanup attribute). In practice, we support various versions
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment