Skip to content

Code Conventions

Jon Voigt Tøttrup edited this page Jun 15, 2018 · 4 revisions

Code conventions are a very important and serious matter. WingCorp is also filled with very important and very, very serious people. Therefore, it is only fitting that we embrace a clearly defined set of coding conventions

Naming convetion:

Global variables (e.g. extern int x = 10; ) and functions are also to be named by camelCase.

Structs are to be named using PascalCase

Macros are to be named using ALL_CAPITAL_LETTERS.

Modules

The code is to be divided into modules.

A module is named in camel case in the folder structure. A module must consist of a simple directory in the ./src/ directory, but can contain multiple sub-directories and .h and .c files.

Each function, struct and global variable within a module that should be visible to other modules must be prefixed with the module name and an undescore _.

Functions

Functions should have clear concise names, usually a function should be verb. However, in order to

Structs

In order to keep the initialization and referencing to structs as simple as possible, typedef'ing should be used whenever possible. This can be done in the following fashion:

typedef struct _StructA {
    int varA;
    int varB;
} StructA;

Clone this wiki locally