How can I force clang-format to indent struct field initializers consistently regardless of length?

Viewed 14

Consider the following two formats.

const struct CanFrames_FrameMetaData BCM_Status_metaData = {.dlc = BCM_Status_DATA_LENGTH,
                                                            .getPeriodicTxEnabled = KamagBattery_IsPeriodicTxEnabled34343,
                                                            .txInterval_ms = 50,
                                                            .txHoldoff_ms = 0,
                                                            .rxTimeout_ms = 1000};

const struct J1939_PgnMetaData J1939PropData1_metaData = {
    .pgnId = 0xFF01U,               // J1939 PGN "Proprietary B, Group 1"
    .priority = J1939_COMMAND_PRIO, // Deviation from J1939 default for backwards compatibility
    .pgnLength = J1939PropData1_DATA_LENGTH,
    .getDynamicLength = NULL,
    .getPeriodicTxEnabled = NULL,
    .txInterval_ms = 50,
    .txHoldoff_ms = 0,
    .rxTimeout_ms = 0};

Which one clang-format produces seems to depend on the length of the fields, init values and comments. How can I force clang-format to always use the latter?

0 Answers
Related