首页 > 解决方案 > 如何防止 clang-format 在#define 列表之前添加换行符

问题描述

我正在尝试做的事情:

#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 }  // R, G, B, W

什么 clang-format 强加给我:

#define NEOPIXEL_BKGD_COLOR \
{ 255, 255, 255, 0 }           // R, G, B, W

如何防止 clang 添加该换行符?

这是我当前的 clang 配置,尽管我已经尝试了几乎所有我知道的选项:

BasedOnStyle: LLVM, 
IndentPPDirectives: BeforeHash, 
ColumnLimit: 0, 
AlignConsecutiveMacros: AcrossEmptyLinesAndComments, 
AlignTrailingComments: true, 
SpacesBeforeTrailingComments: 2, 
IndentWidth: 2, 
TabWidth: 2, 
MaxEmptyLinesToKeep: 1, 
PointerAlignment:  Right, 
SortIncludes: false, 
AlignConsecutiveAssignments: AcrossComments, 
Cpp11BracedListStyle: true

标签: c++clang-format

解决方案


推荐阅读