Skip to content

Commit 4be3b7b

Browse files
authored
Merge pull request #1053 from Unity-Technologies/add-clang-format
Add a clang-format style file to Mono
2 parents 85c0ad3 + 0c3c3e0 commit 4be3b7b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.clang-format

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This is a minimal clang-format file for Mono code. The code is not consistent
2+
# in its formatting, so this file is most often useful with git-clang-format [1],
3+
# which formats only changed lines.
4+
#
5+
# Usage:
6+
# * Make some changes to Mono C code or headers
7+
# * Run `git clang-format` (maybe add -f if there are line ending issues from git)
8+
# * Your changed code should meet the formatting guidelines for Mono
9+
#
10+
# Installation:
11+
# * Install LLVM tools (including clang-format) for your OS [2]
12+
# * Install Pythong on your OS
13+
#
14+
# Code style:
15+
# Our goal is to match the Mono code style, not define a new one. The style
16+
# options [3] are many. Here we try to capture only a few. If you find something
17+
# is missing, feel free to add configuration options.
18+
#
19+
# [1] https://github.com/llvm-mirror/clang/blob/master/tools/clang-format/git-clang-format
20+
# [2] http://releases.llvm.org/
21+
# [3] https://clang.llvm.org/docs/ClangFormatStyleOptions.html
22+
23+
# All function declarations and calls should have a space after the name
24+
SpaceBeforeParens: Always
25+
26+
# Use four space tabs
27+
UseTab: Always
28+
TabWidth: 4
29+
IndentWidth: 4
30+
31+
# Handle curly braces, basically: functions get a line break, nothing else does
32+
BreakBeforeBraces: Custom
33+
BraceWrapping:
34+
AfterControlStatement: false
35+
AfterStruct: false
36+
AfterFunction: true
37+
AfterEnum: false
38+
AfterStruct: false
39+
AfterUnion: false
40+
BeforeElse: false
41+
42+
# Keep function return types on a different line from the function name
43+
# Note that often static function forward declarations don't follow this
44+
# approach, and have the return type on the same line. I'm not sure
45+
# clang-format can handle these two cases differently.
46+
AlwaysBreakAfterReturnType: TopLevel
47+
48+
# Don't warp any long lines
49+
ColumnLimit: 0

0 commit comments

Comments
 (0)