-
Notifications
You must be signed in to change notification settings - Fork 79
MrBayes source code style guide
The MrBayes C source code uses a modified Whitesmiths indentation style.
-
Braces are indented to the block level:
for (i = 0; i < n, ++i) { /* for-loop body */ }
Except for function bodies, i.e. we use
int function (arguments) { /* function body */ }
rather than
int function (argument) { /* function body */ }
Other than that, we also try to adhere to the following formatting criteria:
-
Indent width is 4 spaces (no tabs).
-
Outer parens are padded with space on the outside as to not attach:
function (arguments); if ((type *) variable == variable)
-
Operators are padded with spaces:
(i * j) / 2
-
The pointer operator is attached to the variable, not to the type name:
char *a; /* good */ char * a; /* not used */ char* a; /* not used */
-
Blocks of just one line do not have braces.
-
Preprocessor directives are indented with the code:
int function (arguments) { # if defined (MACRO) /* code */ # endif }
-
Long argument lists in function declarations and function definitions, are not currently broken, although long argument lists in function calls are sometimes broken.
-
Variable declarations in functions occur at the top of the function.
-
Variable names are indented by 16 spaces from the start of the current block indentation level:
typename variable; othertypename othervariable; <----- 16 ----->