-
Notifications
You must be signed in to change notification settings - Fork 244
SDL Coding Style Guide
Basic formatting changes can be fixed using the following command in the SDL Core root folder:
. tools/infrastructure/check_style.sh --fix
Generally we use Google Coding Style with the following exceptions/additions:
-
- Don't use
inlinespecificator.
- Don't use
-
-
Add all
#includeexplicitly. -
Recommended to use short paths in
#includedirectives like:#include "base/logging.h". If component has subcomponents - the longer path can be used according the following rule: The longest path to file in#includedirective must be started from component name (f.e.#include "utils/threads/thread_manager.h"or#include "application_manager/commands/command.h"). Path tocomponentmust be specified inCMakeList.txtasinclude_directories).
-
-
- Using of using-directive to make all names from a namespace available is allowed in method(function) body ONLY
-
- Output parameters must be passed by reference. F.e.
void Foo(const string& in, string& out);-
Templates
- In template definitions
typenameword must be used
- In template definitions
-
-
Only Global const variables must be named with a leading "k" followed by mixed case. F.e.
const int kDaysInAWeek = 7; -
The names of variables and data members are all lowercase, with underscores between words. Data members of classes AND structs additionally have trailing underscores. For instance: a_local_variable, a_struct_data_member_, a_class_data_member_.
-
Enumerators (for both scoped and unscoped enums) should be named either like constants :
kEnumName -
Functions output parameters must have
out_prefix in their names;
-
-
Vertical Whitespaces. They helps visually separate out logical blocks of code. Add one blank line before and after any (first and last line in function/cycle/statement should't be the blank line):
- Cycles (for, while, etc.);
- Statements (if);
- Definition/initialization blocks;
- Logical block of function calls;