<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello,</p>
<p>The systemd codebase is discussing the adoption of clang-format
as the formatting tool for its code base.</p>
<p>See conversation here:
<a class="moz-txt-link-freetext" href="https://github.com/systemd/systemd/pull/11308">https://github.com/systemd/systemd/pull/11308</a></p>
<p>However there are a couple of issues with clang-format for the
systemd common style, which might be solvable by adding some new
additional styles, which also be beneficial for other projects.</p>
<p><br>
</p>
<p><b>Suggestions:</b></p>
<p>- add a custom indent for pp directives</p>
<p>The general indent of the codebase is 8 spaces. But the pp indent
is only two spaces. As the PP are fundamentally different from the
C code, IMHO it makes sense to allow a different indent for these
elements.</p>
<p>Additionally PP are aligned to the very left. Keeping the indent
low helps identifying PP from C code visually, as the PP generally
happens on the left and the C code on the right.</p>
<p>--> new style option "<strong>IndentPPDirectiveWidth</strong>"
which defaults to 0. When zero the IndentWidth<strong> </strong>value
is used for indentation. When greater zero this value is used for
indentation.<strong><br>
</strong></p>
<p><strong><br>
</strong></p>
<p>- no space after foreach macro, with SpaceBeforeParens set to
Always<strong><br>
</strong></p>
<p>systemd is heavily using foreach macros throughout its code. In
general<b> </b><b>SpaceBeforeParens: Always</b><strong> </strong>matches
the style of the project. However the foreach macros should not
have the space between foreach macro name and parens. <br>
</p>
<p>--> add new possible value "<b>ExceptFor</b><strong>EachMacros</strong>"
to <strong>SpaceBeforeParens,</strong> which behaves as <strong>Always,</strong>
except that foreach macros should not have the space between
foreach macro name and parens.<strong>
</strong></p>
<p><br>
</p>
<p>- enum breaking behaviour<strong><br>
</strong></p>
<p>when using enums with an indent width of 8 spaces and no brace
wrapping after enum (BraceWrapping: ... AfterEnum: false)</p>
<p>example:</p>
<p>```<br>
enum { ARG_VERSION = 0x100,<br>
};<br>
```<br>
</p>
<p>i would have expected the following output:<br>
```<br>
enum { <br>
ARG_VERSION = 0x100,<br>
};<br>
```</p>
<p>Is this behaviour intended, or is this a bug?</p>
<p><br>
</p>
<p>Cheers, Sebastian Jennen<br>
<strong></strong></p>
</body>
</html>