<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/145249>145249</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] Formatting a C file only works with Cpp formatting settings
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          hueychen27
      </td>
    </tr>
</table>

<pre>
    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)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVU2vqzYQ_TXOZkRkBkjCggXJVaRKqVqpVd_awQO4NTayzX0vm_72ykDycj_ULqqqCCnOMOM5Z-aMLbxXnSGqWHFkxctGTKG3ruonujU9GdxvrlbeqgsFCL3ycCUIPUGrNDE8AdvxybTWDSIEktuG7Xg0BxsdH3ZQZo6ib2IYNXmW1YzX0Xd-G8ZrUCbA_AxCGYaH-b9wXQNxw6YXDoBhHU2vsIAFhiWw_TGGxyeGRJfQK9Ox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