Does anyone know how to configure clang-format to keep enum's on individual lines?
i.e.
enum {
ONE,
TOW,
THREE
};
vs.
enum {ONE, TWO, THREE};
EDIT:
Here are the style options i use to match Apple's Objective-C style guide.
http://pastebin.com/0cTEhvBv
clang-format supports two ways to provide custom style options: directly specify style configuration in the -style= command line option or use -style=file and put style configuration in the . clang-format or _clang-format file in the project directory.
Clang-Format Style Options are flags that are supported by the ClangFormat tool, which became the de-facto standard to format C++ code. Clang offers the option to use one of the predefined styles (LLVM, Google, Chromium, Mozilla, WebKit, Microsoft) or to create a custom configuration by using the given flags.
Clang is an LLVM native C/C++/Objective-C compiler, which aims to deliver amazingly fast compiles (e.g. about 3x faster than GCC when compiling Objective-C code in a debug configuration), extremely useful error and warning messages and to provide a platform for building great source level tools.
Short answer: YES. The clang-format tool has a -sort-includes option. Changing the order of #include directives can definitely change the behavior of existing code, and may break existing code.
This was intentionally introduced at some stage (so if you are unable to reproduce the behavior, you are likely on an older version).
clang-format contracts enums to a single line if all elements fit on one line. This conserves spaces and usually does not decrease readability. There is no style option, but you can override this by either adding a line comment somewhere or by adding a trailing comma after the last enumerator, e.g.:
enum {
ONE,
TOW,
THREE,
};
or
enum {
ONE, // This means ...
TOW,
THREE
};
AllowShortEnumsOnASingleLine: false
You might need a newer version of clang-format to support this. From https://clang.llvm.org/docs/ClangFormatStyleOptions.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With