以clang格式对齐函数声明

时间:2019-05-02 12:17:15

标签: c++ c clang-format

我在函数声明对齐方面遇到问题。

考虑:

RplInstanceS* RplGetInstance(inst_t instID, uint8_t createFlag);
RplDagS* RplGetDag(RplInstanceS* inst, RplAddrS* dagID, uint8_t createFlag);
void RplFreeInstance(RplInstanceS* inst, uint8_t forced);
void ResetDioTrickle(RplDagS* dag);
RplDagS* GetNextInuseDag(int* state);
void    RplFreeAllInstances(void);
uint8_t CountAllInstances(void);
uint8_t StartAllInstances(void);

我希望可以使用clang格式的选项将其转换为:

RplInstanceS* RplGetInstance(inst_t instID, uint8_t createFlag);
RplDagS*      RplGetDag(RplInstanceS* inst, RplAddrS* dagID, uint8_t createFlag);
void          RplFreeInstance(RplInstanceS* inst, uint8_t forced);
void          ResetDioTrickle(RplDagS* dag);
RplDagS*      GetNextInuseDag(int* state);
void          RplFreeAllInstances(void);
uint8_t       CountAllInstances(void);
uint8_t       StartAllInstances(void);

1 个答案:

答案 0 :(得分:1)

没有特定于函数的选项,但是有AlignConsecutiveDeclarations选项,如果将其设置为true,则它会对齐连续的声明。

此选项可以与PointerAlignment选项一起使用,该选项的值设置为PAS_Left(在配置中:“左”),它将使指针向左对齐。

这两个选项的组合应该可以为您提供所需的内容。