Skip to content

Commit e7655fe

Browse files
Add clang-format style for project
This adds a .clang-format file for the project. Requires clang-format-17: docker run -u 1000 -v $PWD:$PWD xianpengshen/clang-tools:17 \ clang-format -i $(find -name '*.c' | xargs realpath) Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
1 parent 46a1079 commit e7655fe

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

.clang-format

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2023-2024 Infineon Technologies AG
2+
#
3+
# SPDX-License-Identifier: BSD-2-clause
4+
5+
---
6+
7+
BasedOnStyle: GNU
8+
9+
IndentWidth: 4
10+
ColumnLimit: 100
11+
12+
BreakBeforeBraces: Attach
13+
14+
AlignAfterOpenBracket: Align
15+
AlignConsecutiveDeclarations: true
16+
BinPackParameters: false
17+
AllowAllParametersOfDeclarationOnNextLine: false
18+
19+
SpaceBeforeParens: ControlStatementsExceptControlMacros
20+
AlignConsecutiveMacros:
21+
Enabled: true
22+
AcrossEmptyLines: true
23+
AcrossComments: false
24+
25+
Macros:
26+
- statecase(VAR, STATE)=case 0:{}
27+
- general_failure(VAR)=default:{}
28+
- statecasedefault(VAR)=default:{}
29+
- statecasedefault_error(VAR, r, label)=default:{}

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# .git-blame-ignore-revs

doc/coding_standard_c.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ notably is the indentation (more on this later). Above all else we ask
55
that when modifying the code that you follow the most important rule:
66
check the surrounding code and imitate its style [1].
77

8+
## Clang-Format Style
9+
For simplicity, we use clang-format for all files (also as part of the CI).
10+
Thus before commiting any code, we recommend you run
11+
```sh
12+
docker run -u 1000 -v $PWD:$PWD xianpengshen/clang-tools:17 clang-format -i $(find -name '*.c' | xargs realpath)
13+
docker run -u 1000 -v $PWD:$PWD xianpengshen/clang-tools:17 clang-format -i $(find -name '*.h' | xargs realpath)
14+
```
15+
This ensures that the code will not break during your pull request.
16+
817
## C Standard and Compiler Stuff
918
Code should hold as close to the C99 standard as possible with the exception
1019
that GCC specific extensions are generally accepted. The code must compile

0 commit comments

Comments
 (0)