Reputation: 35169
I'm trying to get clang-format
to do my bidding, and stumbling on one point. I want my C function declaration to be formatted as:
sensor_t *sensor_enable_alarm(sensor_t *sensor,
float lo_thresh,
float hi_thresh);
but with my current settings, clang-format wants to format it as:
sensor_t *
sensor_enable_alarm(sensor_t *sensor, float lo_thresh, float hi_thresh);
I've initialized my .clang-format from llvm via:
clang-format -style=llvm -dump-config > .clang-format
and modified just the BinPackParameters
to be false:
BinPackParameters: false
What additional tweaks to .clang-format do I need?
Upvotes: 0
Views: 266
Reputation: 1924
This can be done by setting PenaltyReturnTypeOnItsOwnLine
to a larger value. The default value for LLVM style is 60
. Try 200
, which is the default for Google
, Mozilla
, and Chromium
styles.
For example, clang-format -style='{BasedOnStyle: LLVM, BinPackParameters: false, PenaltyReturnTypeOnItsOwnLine: 200}' yourfile.cpp
gives this output:
sensor_t *sensor_enable_alarm(sensor_t *sensor,
float lo_thresh,
float hi_thresh);
As always, see the documentation for more information. However, unfortunately, there really isn't much there to explain the "Penalty" values.
Upvotes: 1