简体   繁体   中英

How to configure clang-fromat to avoid wrap the brace for enum

I have an enum like this:

enum class Fruit {
  Apple = 0,
  Banana = 1
};

And the .clang-format configurations for the enum looks like this:

BreakBeforeBraces: Attach
AllowShortEnumsOnASingleLine: false
BraceWrapping:
  AfterEnum: false

After applying clang-format, the brace is wrapped and the code become

enum class Fruit 
{
  Apple = 0,
  Banana = 1
};

How to config clang-format to keep the enum's original format?

我认为你的文件有问题,如果BreakBeforeBraces不是Custom你就不能使用BraceWrapping

I think it's a bug. It's currently been fixed here but they haven't release yet:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM