Add clang-format
This commit is contained in:
parent
f57b7c8153
commit
229e3db325
13
c.md
13
c.md
|
@ -9,3 +9,16 @@ int option = 1;
|
|||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
|
||||
```
|
||||
|
||||
## Formatting
|
||||
### `clang-format`
|
||||
- Format all files in-place: `clang-format -i *.c *.h`
|
||||
- Specify format:
|
||||
- Predefined style: `-style=<STYLE>`, e.g. `-style=llvm`
|
||||
- Custom file in current or parent directory: `-style=file`
|
||||
- Create style file based on default: `clang-format -style=llvm -dump-config > .clang-format`
|
||||
- If no `-style` is provided, `-style=file` is used. If there is no `.clang-format`, `-style=LLVM` is used
|
||||
- Use default style, but overwrite some key: `--style={BasedOnStyle: <STYLE>, <KEY>: <VALUE>}`
|
||||
|
||||
### Example
|
||||
- `clang-format --style="{BasedOnStyle: LLVM, IndentWidth: 4, ColumnLimit: 90}" -i *.c *.h`
|
||||
|
|
Loading…
Reference in New Issue