Indentation is four spaces -- no tabs. Only file types that absolutely require tabs (e.g. `Makefile`) may use them.
Variable names use camel case with the first letter lower-case.
Variable names should be descriptive. Avoid
Type names use camel case with the first letter upper case:
typedef struct MemContext <...>
typedef enum {<...>} ErrorState;
#define Constants
#define
constants should be all caps with
The value should be aligned at column 69 whenever possible.
This type of constant should mostly be used for strings. Use enums whenever possible for integer constants.
Enum Constants
Enum elements follow the same case rules as variables. They are strongly typed so this shouldn't present any confusion.
Note the comma after the last element. This reduces diff churn when new elements are added.
Macro names should be upper-case with underscores between words. Macros (except simple constants) should be avoided whenever possible as they make code less clear and test coverage harder to measure.
Macros should follow the format:
If the macro defines a block it should look like:
Continuation characters should be aligned at column 132 (unlike the examples above that have been shortened for display purposes).
To avoid conflicts, variables in a macro will be named
Use
Use
C allows braces to be excluded for a single statement. However, braces should be used when the control statement (if, while, etc.) spans more than one line or the statement to be executed spans more than one line.
No braces needed:
Braces needed:
Don't get exotic - use the simplest type that will work.
Use
Don't use a macro when a function could be used instead. Macros make it hard to measure code coverage.
Object-oriented programming is used extensively. The object pointer is always referred to as
The
Subsequent code that is uncoverable for the same reason is marked with // {+uncoverable}
.
Marks code that is not tested for one reason or another. This should be kept to a minimum and an excuse given for each instance.
Subsequent code that is uncovered for the same reason is marked with `// {+uncovered}`.