Bump version
[yosys.git] / guidelines / CodingStyle
1 Coding Style
2 ============
3
4
5 Formatting of code
6 ------------------
7
8 - Yosys code is using tabs for indentation. Tabs are 8 characters.
9
10 - A continuation of a statement in the following line is indented by
11 two additional tabs.
12
13 - Lines are as long as you want them to be. A good rule of thumb is
14 to break lines at about column 150.
15
16 - Opening braces can be put on the same or next line as the statement
17 opening the block (if, switch, for, while, do). Put the opening brace
18 on its own line for larger blocks, especially blocks that contains
19 blank lines.
20
21 - Otherwise stick to the Linux Kernel Coding Style:
22 https://www.kernel.org/doc/Documentation/CodingStyle
23
24
25 C++ Language
26 -------------
27
28 Yosys is written in C++11. At the moment only constructs supported by
29 gcc 4.8 are allowed in Yosys code. This will change in future releases.
30
31 In general Yosys uses "int" instead of "size_t". To avoid compiler
32 warnings for implicit type casts, always use "GetSize(foobar)" instead
33 of "foobar.size()". (GetSize() is defined in kernel/yosys.h)
34
35 Use range-based for loops whenever applicable.