Add clang-format

This commit is contained in:
Jean-Claude 2023-10-29 19:47:44 +01:00
parent f57b7c8153
commit 229e3db325
Signed by: jeanclaude
GPG Key ID: 8A300F57CBB9F63E
1 changed files with 13 additions and 0 deletions

13
c.md
View File

@ -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`