Skip to content
Matthieu Basset edited this page Mar 18, 2023 · 17 revisions

When the factory Wiki

Welcome to the when-the-factory wiki!

Main Pages:

Code Convetions

(Open to discuss)

Variables

Case

/* 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,

    NUM_TYPES,
};

/* "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;

Conventions about global variables

Usually we define these variables in a relevant source file and refer to them with the extern keyword in the corresponding header file.

Code style

Comments

/* This type of comments are used
 * with this style for multiline comment */

// Double slash comments aren't used

Function documentation convention hasn't been clearly established yet.

Pointers

The star is on the left

/* Good */
int* h;
/* Bad */
int * g;
int *gg;

Code indentation

Tabs are used for indentation in every file.

Brackets and spaces

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 */
    }
} 

Include order

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

Clone this wiki locally