【问题标题】:How to format protobuf file more nicely using clang-format?如何使用 clang-format 更好地格式化 protobuf 文件?
【发布时间】:2019-10-11 10:29:26
【问题描述】:

我正在很好地格式化我的 porotbuf 文件,这是一个示例:

message StealCache {
    string   CurStealTargetUID          = 1;
    uint32   CurStealMoney              = 2;
    repeated TargetList TargetLists     = 3;
    uint32              Count           = 4;
    uint32              Timestamp       = 5;
    StealTreasureBox    StealBox        = 6;
    uint32              ExtraStealMoney = 7;
}

当前的clang-format样式标签是:

{BasedOnStyle: Google, 
AlignConsecutiveDeclarations: true, 
AlignConsecutiveAssignments: true, 
ColumnLimit: 0, 
IndentWidth: 4}

但我想要的是这样的:

message StealCache {
    string              CurStealTargetUID   = 1;
    uint32              CurStealMoney       = 2;
    repeated TargetList TargetLists         = 3;
    uint32              Count               = 4;
    uint32              Timestamp           = 5;
    StealTreasureBox    StealBox            = 6;
    uint32              ExtraStealMoney     = 7;
}

如何修改我的 clang 格式样式?

【问题讨论】:

  • 您使用的是哪个版本的 clang-format?我可以使用您的样式标签获得所需的输出。
  • @RahulSreeram llvm 9.0。相同的标签?
  • 是的。我用的是同一个版本,使用了你指定的样式标签。
  • @RahulSreeram 太奇怪了,你确定你有那个“重复”的行吗?如果你能告诉我你的标签和原型文件,那就太好了。谢谢!

标签: protocol-buffers clang-format


【解决方案1】:

llvm(9.0.0) 升级后,此问题已解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-30
    • 2020-08-28
    • 2014-11-17
    • 1970-01-01
    • 2019-06-18
    • 2013-09-11
    • 2020-07-27
    • 2022-01-23
    相关资源
    最近更新 更多