This document describes the coding-style rules that apply on this repository.
- No tabs or trailing spaces.
- Surround arithmetic and logical operations (
+,-,*,/,&,|,^) with spaces. - Always place a space after a comma (
,). - Indentation size of 4 spaces for *.cpp, *.h files.
- Indentation size of 2 spaces for *.xml, *.json files.
- High-level emulated primitive types should be defined through the following fixed-sized types:
S08,S16,S32,S64for signed integer types.U08,U16,U32,U64for unsigned integer types.F32,F64for floating-point types.
- High-level emulated primitive types bigger than 8-bit byte should be wrapped with
LEorBEdepending on the emulated architecture:LE<T>is a little-endian representation of the typeT.BE<T>is a big-endian representation of the typeT.
- High-level emulated constants should be defined via
enum : type { ... }, where type represents any of the fixed-sized integer types listed above. - Always use
usinginstead oftypedef. - Always use a range-based
forif possible.
- All type names must start with an uppercase character and avoid underscores. High-level emulated types should be declared exactly as they are in the corresponding system, even if it breaks this rule.
- All variable names must start with a lowercase character. High-level emulated variables should be declared exactly as they are in the corresponding system, even if it breaks this rule.
The following layout appplies both to source files (.cpp) and header files (.h).
License. Mandatory comment:
/**
* (c) 2014-2016 Alexandro Sanchez Bach. All rights reserved.
* Released under GPL v2 license. Read LICENSE for more details.
*/Include guard. Only for headers. Do this with:
#pragma onceIncludes. Only if necessary. The following order is preferred:
- Header corresponding to this source file.
- Header files of Nucleus.
- Header files of external dependencies.
- Header files of the Standard Template Library.
Namespace (begin). They do not affect indentation in any way. E.g.:
namespace name {Defines.
Constants.
Types.
Functions.
Namespace (end). Place in a comment what namespace are they closing. E.g.:
} // namespace name