In the codebase I'm working in, we always declare nested namespaces thusly:
namespace foo { namespace detail {
// stuff
} } // foo::detail namespace
I haven't yet been able to find a way to configure clang-format
not to break this out into multiple lines:
namespace foo {
namespace detail {
// stuff
}
} // foo::detail namespace
I've played around with the BreakBeforeBraces
configuration, and I've looked into the new BraceWrapping
configuration in clang 3.8, both without success.
Is it possible to do this without annotating the code with // clang-format [on/off]
?
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.
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.
clang-format file uses YAML format: key1: value1 key2: value2 # A comment. ... The configuration file can consist of several sections each having different Language: parameter denoting the programming language this section of the configuration is targeted at.
clang-format file, we need to place it in the project folder or in any parent folder of the file you want to format. clang-format.exe searches for the config file automatically starting with the folder where the file you want to format is located, all the way to the topmost directory.
It turns out that this is a feature that has been considered by the clang-format team, but has been rejected. For additional details, see https://llvm.org/bugs/show_bug.cgi?id=17928.
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