Skip to content

Commit 18c81fb

Browse files
committed
Add .clang-format file
1 parent 98d2b43 commit 18c81fb

2 files changed

Lines changed: 88 additions & 26 deletions

File tree

.clang-format

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# .clang-format
2+
---
3+
AlignAfterOpenBracket: DontAlign
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlines: Left
7+
AlignOperands: true
8+
AlignTrailingComments: true
9+
AllowAllArgumentsOnNextLine: true
10+
AllowAllParametersOfDeclarationOnNextLine: false
11+
AllowShortBlocksOnASingleLine: Empty
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: None
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: false
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BraceWrapping:
23+
AfterControlStatement: MultiLine
24+
AfterEnum: false
25+
AfterFunction: true
26+
AfterStruct: false
27+
AfterUnion: false
28+
BeforeElse: false
29+
IndentBraces: false
30+
BreakBeforeBinaryOperators: None
31+
BreakBeforeBraces: Custom
32+
BreakStringLiterals: false
33+
ColumnLimit: 80
34+
ContinuationIndentWidth: 8
35+
DerivePointerAlignment: false
36+
DisableFormat: false
37+
ExperimentalAutoDetectBinPacking: false
38+
ForEachMacros:
39+
- SLIST_FOREACH
40+
- SLIST_FOREACH_FROM
41+
- SLIST_FOREACH_FROM_SAFE
42+
- SLIST_FOREACH_SAFE
43+
- SLIST_FOREACH_PREVPTR
44+
- SPLAY_FOREACH
45+
- LIST_FOREACH
46+
- LIST_FOREACH_FROM
47+
- LIST_FOREACH_FROM_SAFE
48+
- LIST_FOREACH_SAFE
49+
- STAILQ_FOREACH
50+
- STAILQ_FOREACH_FROM
51+
- STAILQ_FOREACH_FROM_SAFE
52+
- STAILQ_FOREACH_SAFE
53+
- TAILQ_FOREACH
54+
- TAILQ_FOREACH_FROM
55+
- TAILQ_FOREACH_FROM_SAFE
56+
- TAILQ_FOREACH_REVERSE
57+
- TAILQ_FOREACH_REVERSE_FROM
58+
- TAILQ_FOREACH_REVERSE_FROM_SAFE
59+
- TAILQ_FOREACH_REVERSE_SAFE
60+
- TAILQ_FOREACH_SAFE
61+
IndentCaseLabels: false
62+
IndentWidth: 8
63+
IndentWrappedFunctionNames: true
64+
KeepEmptyLinesAtTheStartOfBlocks: false
65+
MaxEmptyLinesToKeep: 1
66+
PenaltyBreakBeforeFirstCallParameter: 30
67+
PenaltyBreakComment: 10
68+
PenaltyBreakString: 10
69+
PenaltyExcessCharacter: 100
70+
PenaltyReturnTypeOnItsOwnLine: 60
71+
PointerAlignment: Right
72+
ReflowComments: false
73+
SortIncludes: true
74+
SpaceAfterCStyleCast: true
75+
SpaceBeforeAssignmentOperators: true
76+
SpaceBeforeParens: ControlStatements
77+
SpaceInEmptyParentheses: false
78+
SpacesBeforeTrailingComments: 1
79+
SpacesInContainerLiterals: false
80+
SpacesInCStyleCastParentheses: false
81+
SpacesInParentheses: false
82+
SpacesInSquareBrackets: false
83+
TabWidth: 8
84+
UseTab: Always

STYLE-GUIDE.md

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,10 @@ or fixes you might notice.
77

88
## C CODE
99

10-
The BSD Kernel Normal Form (KNF) style is used [1]. Basically, it is like
11-
K&R/LKML, but wrapped lines that are indented use 4 spaces. Here are the
12-
highlights.
13-
14-
- no trailing whitespace
15-
- indented code use tabs (not line wrapped)
16-
- cuddle the braces (except for functions)
17-
- space after native statements and before paren (for/if/while/...)
18-
- no space between function and paren
19-
- pointer asterisk cuddles the variable, not the type
20-
21-
```
22-
void foo(int c)
23-
{
24-
int ret = 0;
25-
26-
if (c > 1000)
27-
return;
28-
29-
while (c--) {
30-
bar(c);
31-
ret++;
32-
}
33-
34-
return ret;
35-
}
10+
This project uses clang format to define the code style. To format code
11+
automatically, run the following command:
12+
```bash
13+
$ clang-format --style=file -i path/of/source/file
3614
```
3715

3816
## COMMIT MESSAGES

0 commit comments

Comments
 (0)