Coding style in markdown.

This commit is contained in:
Florian Pose 2023-01-30 11:00:53 +01:00
parent d34e5a60d4
commit 97f101acb6
2 changed files with 39 additions and 36 deletions

View File

@ -1,5 +1,3 @@
$Id$
vim: spelllang=en tw=78 vim: spelllang=en tw=78
This is a short introduction to the coding style that shall be used. The below This is a short introduction to the coding style that shall be used. The below
@ -7,11 +5,11 @@ rules are applicable for all C source files, except the Ethernet drivers, for
which the Linux Kernel coding style shall be used to minimize the which the Linux Kernel coding style shall be used to minimize the
differences). differences).
1) Line length # Line length
- Lines shall not exceed 78 characters. - Lines shall not exceed 78 characters.
2) Whitespace # Whitespace
- Indentation shall be done using 4 space characters - Indentation shall be done using 4 space characters
@ -20,36 +18,39 @@ differences).
- After commas, colons and semicolons, a single space shall be - After commas, colons and semicolons, a single space shall be
placed (if not followed by a line break). placed (if not followed by a line break).
- Binary operators (=, ==, ~=, |, ||, etc.) shall be enclosed by 2 spaces - Binary operators (`=`, `==`, `~=`, `|`, `||`, etc.) shall be enclosed by 2 spaces
(except . and ->). (except `.` and `->`).
3) Placing braces # Placing braces
- Braces shall be placed in the following way (K&R style): - Braces shall be placed in the following way (K&R style):
if (...) { ```c
if (...) {
... ...
} else if (...) { } else if (...) {
... ...
} else { } else {
... ...
} }
int function(...) int function(...)
{ {
... ...
} }
```
4) Defines and Macros # Defines and Macros
- Defines and macros shall be named in CAPITAL letters. If a macro contains - Defines and macros shall be named in CAPITAL letters. If a macro contains
multiple statements, they should be enclosed by a 'do {} while (0)' loop. multiple statements, they should be enclosed by a 'do {} while (0)' loop.
Macro parameters shall also be capital letters and shall be enclosed py Macro parameters shall also be capital letters and shall be enclosed py
parantheses if necessary. parantheses if necessary.
#define MACRO(A, B) \ ```c
#define MACRO(A, B) \
do { \ do { \
if ((A) == 1) { \ if ((A) == 1) { \
statement(B); \ statement(B); \
} while (0) } while (0)
```

View File

@ -3,12 +3,12 @@ This is the README file of the IgH EtherCAT Master.
vim: spelllang=en spell tw=78 vim: spelllang=en spell tw=78
Contents: Contents:
- general-information - (#general-information)
- requirements - (#requirements)
- building-and-installing - (#building-and-installing)
- realtime-and-tuning - (#realtime-and-tuning)
- license - (#license)
- coding-style - (#coding-style)
# General Information # General Information
@ -19,11 +19,13 @@ information, see http://etherlab.org/en/ethercat.
or contact or contact
> Dipl.-Ing. (FH) Florian Pose <fp@igh.de> >>>
> Ingenieurgemeinschaft IgH Dipl.-Ing. (FH) Florian Pose <fp@igh.de>
> Nordsternstraße 66 Ingenieurgemeinschaft IgH
> D-45329 Essen Nordsternstraße 66
> http://igh.de D-45329 Essen
http://igh.de
>>>
# Documentation # Documentation
@ -108,4 +110,4 @@ property and similar rights of Beckhoff Automation GmbH.
# Coding Style # Coding Style
Developers shall use the coding style rules in the [coding style Developers shall use the coding style rules in the [coding style
file](CodingStyle.txt). file](CodingStyle.md).