Issue |
145249
|
Summary |
[clang-format] Formatting a C file only works with Cpp formatting settings
|
Labels |
clang-format
|
Assignees |
|
Reporter |
hueychen27
|
Let this be the file, `unformatted.c`, to be formatted in the examples:
```c
int main(int argc , char * argv [] ) {
int * thing;
int *eee;
}
```
This will not format the C code at all as `clang-format` returns `Configuration file(s) do(es) not support C++:`
```yaml
---
Language: C
IndentWidth: 9
PointerAlignment: Left
```
Adding `BaseOnStyle: LLVM` to the top of the file will run without an error, but the custom settings defined are ignored:
```yaml
BasedOnStyle: LLVM
---
Language: C
IndentWidth: 9
PointerAlignment: Left
```
Formatted file:
```c
int main(int argc, char *argv[]) {
int *thing;
int *eee;
}
```
For some reason, changing `Language: C` to use Cpp works.
```yaml
BasedOnStyle: LLVM
---
Language: Cpp
IndentWidth: 9
PointerAlignment: Left
```
Formatted file:
```c
int main(int argc, char* argv[]) {
int* thing;
int* eee;
}
```
Why is `Language: C` ignored?
clang-format version:
```
$ clang-format-21 --version
Debian clang-format version 21.0.0 (++20250612091244+3f0cf742ac4e-1~exp1)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs