clang-format Style for RTEMS

Mikail Yayla myayla1245 at gmail.com
Fri Dec 14 12:07:58 UTC 2018


Hello,

we are trying to describe the rtems formatting style using clang-format (
http://clang.llvm.org/docs/ClangFormatStyleOptions.html).
To see whether it can be done, we used ratemonperiod.c as an example and
tried to set up a .clang-format file to describe the formatting.
In the mail added the .clang configuration file and a
ratemonperiodWKCustom_Commented.c, which is ratemonperiod.c with the
configuration in .clang-format applied.

With the .clang-format file in the folder with the source files, it can be
tried out with:
clang-format -style=file original_source.c > formatted_source.c

There are several problems in ratemonperiodWKCustom_Commented.c using
clang-format:

1. In line 30-32, we can see that the "*" of the pointers are not aligned
to the right. This is not supported yet it clang-format (see
https://stackoverflow.com/questions/38392889/clang-format-align-asterisk-of-pointer-declaration-with-variable-name
).

2. In line 32, the ")" at the end of the parameter list needs to be in a
new row, but this doesn't seem to be supported in clang-format.

4. In line 44: If the function call is split into multiple rows, the ");"
should always be in a new row.

5. Also in line 44, when a function call is split into multiple rows. The
parameters can all be in separate rows, but clang-format always puts all
the parameters in one row when they fit.

6. In line 80, clang-format does not stick to the column limit of 80. The
line is 81 long. I have tried to configure a strict 80 column rule with the
penalties, but there are still lines with 81 characters.

7. In line 127, I can't turn off the break after the function return type
in this case.

8. In line 127, the parameter is not in a new line, but in rtems we would
need every parameter of a function definition to always be in seperate
line. Line 182, 279 have the same problem.

8. Lines 323, 330, 335, 348: It should be possible to specify that the
functions arguments can be in seperate rows.

We have also asked the clang community how much effort it would take to
implement these points.

Best,
Mikail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20181214/8e3bd524/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .clang-format
Type: application/octet-stream
Size: 3275 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/devel/attachments/20181214/8e3bd524/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ratemonperiodOriginal.c
Type: text/x-csrc
Size: 10540 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/devel/attachments/20181214/8e3bd524/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ratemonperiodWKCustom_Commented.c
Type: text/x-csrc
Size: 11050 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/devel/attachments/20181214/8e3bd524/attachment-0003.bin>


More information about the devel mailing list