是否可以使用 clang-format
将结构成员和函数参数名称格式化为列?
例如:
struct
{
int alpha; //aligned to 'b' of "beta"
unsigned int beta;
MyObject *gamma; //aligned with 'g' not '*'
};
void foobar (int alpha, //aligned to 'b' of "beta"
unsigned int beta
MyObject *gamma) //aligned with 'g' not '*'
{
}
如果不可能,我可以通过某种方式扩展 clang-format 来实现这一点吗?
最佳答案
clang-format
最近(3.7 或 3.8)获得了更多调整对齐的选项,我在问题中提出的问题仍未得到完全支持,但我们现在可以更接近一点:
AlignConsecutiveDeclarations: true
对齐如上所示的声明。
不幸的是,指针星号的格式控制似乎仍然有限,请参阅 clang-format: Align asterisk (*) of pointer declaration with variable name
关于c - 如何以 clang 格式对齐函数参数名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32682426/