... | ... | @@ -72,21 +72,29 @@ Clang-format is a tool that helps mantaining the code clean and consistent with |
|
|
|
|
|
There are many plugins out there for most of the IDEs (Vim, Visual Studio, Eclipse...).
|
|
|
Otherwise you can run it from terminal:
|
|
|
`cat source.cpp | clang-format > nice_style_source.cpp`
|
|
|
```
|
|
|
cat source.cpp | clang-format > nice_style_source.cpp
|
|
|
```
|
|
|
or
|
|
|
`clang-format -i source.cpp`
|
|
|
```
|
|
|
clang-format -i source.cpp
|
|
|
```
|
|
|
or
|
|
|
`find src/ -iname "*.cpp" -exec clang-format -i "{}" \;`
|
|
|
```
|
|
|
find src/ -iname "*.cpp" -exec clang-format -i "{}" \;
|
|
|
```
|
|
|
(Remember the `src/`, otherwise the whole Miosix codebase will be formatted).
|
|
|
|
|
|
|
|
|
Clang-format will search for a file called `.clang-format` in the working folder
|
|
|
or parent folders. If it doesn't find it, a default format will be used (you can tell
|
|
|
or parent folders (in Boardcore it should be in the root folder).
|
|
|
If it doesn't find it, a default format will be used (you can tell
|
|
|
it's using the default style if you see spaces between `()` ).
|
|
|
|
|
|
Sometimes it uses a strange indentation for enums. In general, if you don't want
|
|
|
a particular part of the code to be touched by clang-format, put it inside a:
|
|
|
```
|
|
|
|
|
|
```cpp
|
|
|
// clang-format off
|
|
|
...codice da non toccare
|
|
|
// clang-format on
|
... | ... | @@ -222,5 +230,5 @@ TODO: |
|
|
|
|
|
What's Next
|
|
|
-------------
|
|
|
Check some [Best Practices](../wiki/Best-Practices) or
|
|
|
Once you've read these guidelines, you can check some [Best Practices](../wiki/Best-Practices) or
|
|
|
start [Writing a Driver](../wiki/Writing-a-Driver). |
|
|
\ No newline at end of file |