Contributions are expected to adhere to these guidelines.
-## Migration from C
+## C++
+
+### Migration from C
As the LTTng-tools project aims at supporting a broad range of compilers -- currently starting from GCC 4.8 and Clang 3.3 -- its build system is configured to use the C++11 standard.
However, new contributions are expected to conform the C++ style described in this guide. Some exceptions are allowed for small fixes which have to be back-ported to stable branches.
-## Automated formatting
+### Automated formatting
All the project's C++ files follow the [clang-format](https://clang.llvm.org/docs/ClangFormat.html) [style](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) of the `.clang-format` file for whitespaces, indentation, and line breaks.
If you are submitting a change to existing source files, _do not run clang-format on the whole file_ as this may introduce more changes than you intended and _will_ cause your changes to be rejected.
-## Tabs VS Spaces
+### Tabs VS Spaces
While our founding mothers and fathers eschewed any consideration for non-English languages when designing the ASCII character encoding they, in a rare moment of technical decadence, decided to dedicate a character to the sole purpose of expressing tabulations.
Note that while tab characters are used for semantic indentation purposes, spaces are perfectly fine to use for _visual_ alignment (e.g. ascii diagrams).
-## Single line control flow statements
+### Single line control flow statements
Single line control flow statements (if/for/while) are required to use braces.
}
```
-## Naming
+### Naming
- Use snake case (e.g. `a_snake_case_name`) except for template parameters, which use camel case and end with `Type` (e.g. `ACamelCaseNameType`).
- Do not make-up abbreviations to shorten names. Term of art abbreviations are, however, acceptable. For example: `mpeg`, `ctf`, `cfg`, `init` are accepted. A notable exception to this rule applies to namespaces, see the "Use of namespaces/Aliases" section.
-## Comments
+### Comments
In general, comments should focus on _why_ something is done and document the assumptions the code was built upon. They should not repeat what it does in plain english except if the code is particularily complex. Keep in mind that what may be obvious to you right now may not be obvious to reviewers... or your future self.
/* Good: The configuration must be initialized before replying since it initializes the user's credentials. */
```
-## Include guards
+### Include guards
Header files must use include guards to prevent multiple inclusion issues. To avoid collisions, the name of include guards must be as specific as possible and include the name of the file.
```
-## Use of namespaces
+### Use of namespaces
Make liberal use of namespaces. Very little should be available in the `lttng`,
let alone global, namespace.
Moreover, prefer to use anonymous namespaces to the `static` keyword to restrict the visibility of a symbol to its translation unit.
-### Do not pollute the global namespace
+#### Do not pollute the global namespace
Never use the `using` directive to import the contents of a namespace. If a namespace is used often in a file, define an alias.
-### Aliases
+#### Aliases
Within a translation unit, it is acceptable to abbreviate commonly-used namespace names to define an alias. For instance, the file containing the implementation of the `food::fruits::citrus::grapefruit` can use the `ffc` namespace alias for brievety.
}
```
-## File layout example
+### File layout example
```cpp
/*
#endif /* LTTNG_THING_DOER_H */
```
-## Miscelaneous guidelines
+### Miscelaneous guidelines
In general, the project’s contributors make an effort to follow, for C++11 code: