[PATCH 2/2] clang-format: align consecutive macros

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Aug 19 07:39:56 PDT 2026


From: Michael Riesch <michael.riesch at wolfvision.net>

clang-format 9 introduced the option "AlignConsecutiveMacros".
Set it to "AcrossEmptyLinesAndComments" in order to avoid macro
definitions of the form:

    #define MAGIC_REGISTER_1 0x42
    #define MAGIC_REGISTER_BIT_FLIP BIT(2)
    /* important comment */
    #define MAGIC_REGISTER_BIT_ENABLE BIT(12)

    #define MAGIC_REGISTER_2 0x43

With the option set to "AcrossEmptyLinesAndComments", they will
be converted to

    #define MAGIC_REGISTER_1	      0x42
    #define MAGIC_REGISTER_BIT_FLIP   BIT(2)
    /* important comment */
    #define MAGIC_REGISTER_BIT_ENABLE BIT(12)

    #define MAGIC_REGISTER_2	      0x43

which seems to be the convention in the kernel code base.

Signed-off-by: Michael Riesch <michael.riesch at wolfvision.net>
Reviewed-by: Nathan Chancellor <nathan at kernel.org>
Signed-off-by: Michael Riesch <michael.riesch at collabora.com>
Link: https://lore.pengutronix.de/20250210-clang-format-fixes-v2-2-37894413bbee@collabora.com
Suggested-by: Fabian Pflug <f.pflug at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 .clang-format | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.clang-format b/.clang-format
index 1f310cfef5c6..d0846dccc0c3 100644
--- a/.clang-format
+++ b/.clang-format
@@ -13,6 +13,7 @@ AccessModifierOffset: -4
 AlignAfterOpenBracket: Align
 AlignConsecutiveAssignments: false
 AlignConsecutiveDeclarations: false
+AlignConsecutiveMacros: AcrossEmptyLinesAndComments
 AlignEscapedNewlines: Left
 AlignOperands: true
 AlignTrailingComments: false
-- 
2.47.3




More information about the barebox mailing list