Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,34 @@ private:

Function names are lowercase with underscores between words.

## Header files

### Protecting agains multiple inclusion

Public header files should be protected with a `#ifndef / #define` guard that mimicks the path (excluding
the initial `include` folder) and the filename, and surrounded with underscores.
For instance, header file `include/fastdds/dds/core/LoanableArray.hpp` should use `_FASTDDS_DDS_CORE_LOANABLEARRAY_HPP_`.
To avoid guards duplicity, underscores and any character that cannot be used on a `#define` are forbidden on folder names.

If a filename has any character not usable on a `#define` it is removed when doing the conversion,
but the presence of such characters is discouraged.
For instance, header file `include/fastdds/header-one.hpp` would use define `_FASTDDS_HEADERONE_HPP`.
It is thus forbidden to have two headers on the same folder with names that differ only on special characters (having
`header-one.hpp` you cannot have `header_one.hpp` or `headerone.hpp`)

### Header contents

A header should only contain one of the following contents:

* the declaration of a single struct/class, along with related static operators
* a bunch of constants on a single namespace
* a bunch of free functions on a single namespace

### Including headers

Using angle brackets `#include <header>` is prefered over double quotes `#include "header"`, as it allows to mock a header
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be preferred the faster option for the preprocessor. If the path is relative, we should use #include "common/Types.hpp". If the path is not relative, we should use #include <fastdds/dds/core/Types.hpp>.

I can understand that a relative path with .. is not liked to be used because visual prettiness, like #include "../rtps/Common.hpp". Although my hand will not shake writing that. All for help to the speed of compilation.

And in case a #include "header" interferes with a mock, always we can change it to #include <header>.

file by prepending a folder when on the compiler command.

## C++ Features

### nullptr
Expand Down