I have this line of code in C++
while (fread(pixel_array++, sizeof(byte), 3, fp));
but when I use clang-format, it splits the semicolon and add it into a new line
while (fread(pixel_array++, sizeof(byte), 3, fp))
;
I don't like this kind of style, and I just prefer to keep the original one.
How should I modify my clang-format configuration? Thanks.
clang-format 5.0 currently doesn't recognize that type of loop. Unfortunately as of clang-format version 5, you won't get a setting that does what you need.
Looking up the Clang Format Style Options, the closest that I've found is AllowShortLoopsOnASingleLine: true
, but that setting doesn't recognize the loop condition as being the body of the loop.
As long as clang-format doesn't recognize those kinds of loops, what I'd do is to mark it your code with // clang-format off
and then // clang-format on
around your block of code.