Home > Blockchain >  There are always line breaks after an enum declaration
There are always line breaks after an enum declaration

Time:02-15

I have the following BraceWrapping options:

BraceWrapping:
  AfterEnum: false
  AfterStruct: false
  SplitEmptyFunction: false
  AfterControlStatement: "Never"
  AfterFunction: false
  AfterNamespace: false
  AfterUnion: false
  AfterExternBlock: false
  BeforeCatch: false
  BeforeElse: false
  BeforeLambdaBody: false
  BeforeWhile: false

However, clang-format always inserts a new line after an enum:

enum class event_flags : std::uint8_t
{
    running = 1 << 0,
    executed = 1 << 1,
};

I want it to be like this:

enum class event_flags : std::uint8_t {
    running = 1 << 0,
    executed = 1 << 1,
};

what am I doing wrong here?

CodePudding user response:

The one option I could find that seems to fix this formatting for you is outside the BraceWrapping section and that is setting

AllowShortEnumsOnASingleLine: true

even though the description of that option doesn't mention it:

true:

enum { A, B } myEnum;

false:

enum {
  A,
  B
} myEnum;
  • Related