-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the when-the-factory wiki!
(Open to discuss)
/* Constants in SCREAMING_SNAKE_CASE
* as well as enum members */
#define NICE_CONSTANT
/*This is the style used for enums, skip line if there is a member counter */
enum Types {
TYPE_1,
TYPE_2,
TYPE_3,
TYPES_NUM,
};
/* "Usual" variables in snake_case */
int some_variable = 0;
/* Special case for gloal variable indexed by "g_" */
SomeType g_global_variable;
/* Custom structs and enums are in PascalCase */
struct CustomType {
int x, y;
};
typedef struct CustomType CustomType;For enums the name of the counter if there is one should be ENUM_NAME_NUM.
Usually we define these variables in a relevant source file and refer to them with the extern keyword in the corresponding header file.
/* This type of comments are used
* with this style for multiline comment */
// Double slash comments aren't usedFunction documentation convention hasn't been clearly established yet.
The star is on the left
/* Good */
int* h;
/* Bad */
int * g;
int *gg;Tabs are used for indentation in every file.
The tab size is set at 3 spaces for the code.
Opening brackets are on the same line as what they are inked to. Spaces are often left before parentheses and brackets.
for (int i = 0; i < 100; ++i) {
while (i < value) {
/* Code */
}
}The case keywords are one lever deeper in indentation than the switch keyword they are linked to. The break keywords are aligned with the cases to avoid forgetting one, an exception being some one-liners cases
For example:
switch (x) {
case 1:
/* code */
break;
case 2:
/* code */
break;
case 3: /* one-liner code*/ break;
}The maximal length for a line of code should be 100 characters.
Header files includes are always grouped by categories, these categories being
- Standard headers
- Third-party headers
- Local headers
There is no specific order among these categories. Nor there is obligation to separate these categories by empty lines

