Waffle's coding style is heavily influenced by the Linux kernel and XCB.

When in doubt, follow the style of nearby code.


Naming
======
All symbols exposed in the public API must be prefixed with `waffle_` or
`WAFFLE_`.

No camelCase, itIsSoHardToRead, especiallyWhenTheVariableNameContainsAnUpperCaseAcronym.

Function and variable names are lower_case_with_underscores.

Enum and macro names are UPPER_CASE_WITH_UNDERSCORES.


Comments
========
Non-Doxygen comments begin with '//'. Do not use '/*'-style comments.
There are special exceptions, such as when commenting items in a table. Use
your judgement.

Doxygen comments begin with '///' or '//!'.


Indentation
===========
Indent 4 spaces. No tabs.

Place a function's return type on its own line. This ensures that all function
names are aligned and makes it easier to quickly find a function when scanning
the source.

    void
    make_coffee(int x, int y);

If a function prototype has a longwinded parameter list, then indent it like this:

    void
    make_fancy_coffee(
        struct coffee_mug *mug,
        struct french_press *press,
        struct sugar_dish *sugar);

or this:

    void
    make_fancy_coffee(struct coffee_mug *mug,
                      struct french_press *press,
                      struct sugar_dish *sugar);

Indent cases in switch statements. The last case always requires a jump
(break, return, goto).

    switch (time) {
        case 600:
        case 1545:
            wake_up();
            break;
        case 1500:
        case 2200:
            sleep();
            break;
        default:
            breathe();
            break;
    }

Don't put multiple statements on a single line.

    BAD:
        if (condition) do_something;

    GOOD:
        if (condition) {
            do_something;
        }


Spaces
======
Leave no trailing whitespace on end of lines. This can cause spurious commit
conflicts.

A single empty line separates function and struct defintions.

Do not add spaces inside a parenthesized expression.

    bad: foo( x, y );

Place a space after these keywords:
    if, switch, case, for, do, while

For keywords that are typically used as functions, do not follow the keyword
with a space and do enclose the arguments with parentheses. The keywords are:
    sizeof, typeof, alignof, __attribute__

When declaring a variable or argument with pointer type, the '*' goes adjacent
to the variable or argument name.

    void
    make_fancy_coffee(
        struct coffee_mug *mug,
        struct french_press *press,
        struct sugar_dish *sugar)
    {
        void *mystery_ingredient = mug + press + sugar;
        ...
    }

No spaces around unary operators.
    --y;
    !z;

No spaces around the structure member operators: '.' and '->'.
    cow->tail
    teapot.spout

Place a single space before and after the binary operators.
    a + b
    x == y
