blob: 1f96c5731f613e492a240018f07ac0a5d081947f [file] [log] [blame]
Imre Kisa21712e2019-10-08 12:56:59 +02001Coding Style & Guidelines
2=========================
3
4The following sections contain |FTB| coding guidelines. They are continually evolving and should not be considered "set
5in stone". Feel free to question them and provide feedback.
6
7The |FTB| project uses multiple "domains" (textual content types, like programming languages) and each defines its own
8rules.
9
10To help configuring text editors the project comes with "`EditorConfig`_" file(s). (:download:`../../.editorconfig`).
11
12Shared rules
13------------
14
15The following rules are common for all domains, except where noted otherwise:
16
17#. Files shall be **UTF-8** encoded.
18#. Use **Unix** style line endings (``LF`` character)
19#. The primary language of the project is English. All comments and documentation must be in this language.
20#. Trailing whitespace is not welcome, please trim these.
21
22C/C++ Domain
23------------
24
25C source code rules are base on the *Linux Coding Style* (See: |LCS|). The following deviations apply:
26
275. C code in |FTB| follows *ISO/IEC 9899:1999* standard.
28#. C++ code in |FTB| follows *ISO/IEC 14882:2011* standard (C++ 11)
29#. Line length shall not exceed 100 characters.
30#. Use `snake_case`_ for function, variable and file names.
31#. Each file shall be "self contained" and include header files with external dependencies. No file shall depend on
32 headers included by other files.
33#. Include ordering: please include project specific headers first and then system includes. Please order the files
34 alphabetically in the above two groups.
35#. All variables must be initialized.
36
37CMake domain
38------------
39
4011. CMake file names use `CamelCase`_ style.
41#. Indent with tabs and otherwise use spaces. Use 4 spaces for tab size.
42#. Use LF as line end in CMake files.
43#. Remove trailing whitespace.
44#. Maximum line length is 128 characters.
45#. When complicated functionality is needed prefer CMake scripting over other languages.
46#. Prefix local variables with `_`.
47#. Use functions to prevent global name-space pollution.
48#. Use `snake_case`_ for function and variable names.
49#. Use the ``include_guard()`` CMake function when creating new modules, to prevent multiple inclusion.
50#. Use self contained modules, i.e. include direct dependencies of the module.
51#. Use the Sphinx CMake domain for in-line documentation of CMake scripts. For details please refer to the
52 `CMake Documentation`_.
53
54Restructured Text Domain
55------------------------
56
57Please refer to :ref:`Writing documentation`.
58
59--------------
60
61.. _`CamelCase`: https://hu.wikipedia.org/wiki/CamelCase
62.. _`snake_case`: https://en.wikipedia.org/wiki/Snake_case
63.. _`CMake Documentation`: https://github.com/Kitware/CMake/blob/master/Help/dev/documentation.rst
64.. _`EditorConfig`: https://editorconfig.org/
65.. _`Uncrustify`: https://github.com/uncrustify/uncrustify
66
67*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
68
69SPDX-License-Identifier: BSD-3-Clause