Update 'Coding Style'

Patrick Vogler 2023-06-22 13:57:29 +00:00
parent d0ed94577c
commit b58ac21058

@ -21,6 +21,7 @@ This document discusses practices and style for programmers working on the BigWh
- [Line Continuation](#line-continuation)
- [Braces](#braces)
- [Whitespace](#whitespace)
- [Conditions](#conditions)
- [Functions](#functions)
- [Derived Types](#derived-types)
- [Comments](#comments)
@ -98,6 +99,29 @@ error = initialize_tagtree (
prec_control->numCbTS);
exit (error);
```
Forumlas always break before binary operations with the new lines aligned to the first operand in the mathematical formulation:
```c
# Correct
prec_control->numCodeblocks_a = (uint64) (prec_control->numCbX
* prec_control->numCbY
* prec_control->numCbZ
* prec_control->numCbTS);
stream->L = stream->L
+ stream->Lmax
+ stream->t;
# Wrong
prec_control->numCodeblocks_a = (uint64) (prec_control->numCbX *
prec_control->numCbY *
prec_control->numCbZ *
prec_control->numCbTS);
stream->L = stream->L +
stream->Lmax +
stream->t;
```
### Braces
@ -256,6 +280,8 @@ if (stream->T == 0xFF) return stream->L + 1; else return stream->L;
Do eliminate trailing whitespace on any line, preferably as a separate patch or commit. Never use empty lines at the beginning or at the end of a file.
### Conditions
### Functions
The following general rules should be followed when defining a function in BigWhoop:
* Function name must be lowercase, optionally separated with underscore _ character
@ -313,12 +339,6 @@ For header files, the function prototypes must be vertically aligned in six colu
```
Each column is marked by the function delimiter with a `|` with each element in the column right aligned to the column seperator. The delimiter must precede every function prototype except the first.
```c
prec_control->numCodeblocks_a = (uint64) (prec_control->numCbX
* prec_control->numCbY
* prec_control->numCbZ
* prec_control->numCbTS);
```
### Derived Types
## Comments