<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117706>117706</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-Format removes space after preprocessor directive
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RobertZickler
</td>
</tr>
</table>
<pre>
Give the following test code:
```c
// Good test
#error My error message
#error - My error message
#error == My error message
#error # My error message
#error + My error message
// Bad test
#error -- My error message
#error ++ My error message
#error . My error message
#error ## My error message
#error (My error message)
#error ++My error message
// ^^^
```
Clang-Format (v19.1.0) formats it like this:
```c
// Good test
#error My error message
#error - My error message
#error == My error message
#error # My error message
#error + My error message
// Bad test
#error-- My error message
#error++ My error message
#error. My error message
#error## My error message
#error(My error message)
#error++ My error message
// ^^^
```
The space after the preprocessor directive is sometimes removed. That is leading to _dodgy_ code. This also happens with `#warning` and probably more directives.
This can be avoided by using quotes, but they are not required.
On a side note: This is leading to a MISRA-C:2012 required warning on the bad formatted lines (rule 20.13).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzclM9u4zYQxp-Gugws8I8sWwcd7KRe9LAosN1TLwtKHEtsKFHhUA789oVot0mQxL4XIGBbM575jT7Op4lsNyLWbL1n68dMz7H3of7hGwzxL9s-OQxZ4825_mZPCLFHOHrn_IsdO4hIEVpvkKkd4-mU_HLa5Yc8MHmAb96blJoeKQzBB_h-hsuXAYl0h29jq5tRph6ZerydItWd-P7zeOLd64-4qztMcv9lzWtKfo_4PvT2Q1hWHym-Hoytf7ueN0IxvntweuxWBx8GHZc2J1HlIudMVnBMDwlsBGefFv0t_d_Fvq31falvKn1f6Ls63yJIM8GXSjO--9kj0KRbBH2MGNJGTwGn4Fsk8gGMDdjGZdktAfkBox2QIODgT2hy-NnruIQcapNMwMMv4013_pWsYEmwBNqRh15PE44ELzb2sBBI9aLDaMeOlRz0aGAKvtGNO8PgA762pvxfWEvQ6hEaBH3y1qCB5gwzLY2fZx-RmHyAZo7LHGfQAWH0EQI-zzaguZb5YwQNZE0KLmZ1YXw_hIbvv__5Y7d6YGonuZD_FYErM_gxva1Gm-teRDTg7Ii0bE2YHYLkuVBMVnlmamUqVekMa7FRspRyzTdZX_OiFHxTtKptRVUcRSWqbYlbU1Yc-daozNaSy0IIWQrJRbHJG8FlU63Vtji2qhKKFRwHbV3u3GnIfegySzRjLcRmw8vM6QYdJT-Xsk2rfaFlUi4OH-rlf6tm7ogV3FmK9Fop2uiwfmcIF-Hp3aX5_MJkc3B1H-OULCLdxc7Gfm7y1g9MHpYu14_VFPzf2EYmDwmemDxc-U-1_CcAAP__DWkYHQ">