[Development] Resolving coding style contentions

Elvis Stansvik elvstone at gmail.com
Wed Nov 21 20:35:09 CET 2018

Den ons 21 nov. 2018 kl 20:28 skrev Matthew Woehlke <mwoehlke.floss at gmail.com>:
> On 21/11/2018 14.11, Ville Voutilainen wrote:
> > On Wed, 21 Nov 2018 at 19:51, Matthew Woehlke wrote:
> >> On 20/11/2018 03.28, Lars Knoll wrote:
> >>> I suggest that we stop arguing about coding styles by defining one
> >>> through a tool (aka clang-format and one format file for all of Qt).
> >>
> >> Ugh... clang-format is only okay if you want LLVM's code style, and it
> >
> > It has been used successfully in projects that don't use LLVM's style.
> Really? When I looked into using it for one of my work projects, it was
> hopelessly unconfigurable and was going to necessitate switching to a
> significantly different code style than what most of the code was using.

We use the following .clang-format at work:

Standard: Cpp11
ColumnLimit: 0
SortIncludes: true
IncludeIsMainRegex: "(Test)?$"
BasedOnStyle: WebKit
PointerAlignment: Right
AlignAfterOpenBracket: Align
BreakBeforeBraces: Custom
    AfterClass: true
    AfterControlStatement: false
    AfterEnum: false
    AfterFunction: true
    AfterNamespace: false
    AfterStruct: true
    BeforeCatch: false
    BeforeElse: false
    IndentBraces: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]

I'd say it's Qt/KDE-ish. Certainly not perfect by any means, and yea
clang-format can do some quite annoying stuff (the re-flowing you

But for the most part, we just get on with it and live with some less
then perfect formatting for some things. All in all it's been a real
relief for all involved since we started mandating all code to be
auto-formatted, and saves a lot of time at review.

I'll definitely look at uncrustify though, thanks for the tip (and for
building it!).


> Okay, pedantically, LLVM *or Google*, or I think there are maybe 1-2
> other styles it supports... However, if what you want deviates from
> those presents, your choices are either a) too bad, change the code
> style of your entire source base, or b) don't use clang-format.
> Clang-format simply doesn't have the configurability to support anything
> beyond its "blessed styles" with a very small number of possible tweaks.
> I haven't looked into whether Qt's is one of those "blessed styles". If
> it is... fine, whatever. If it isn't, uncrustify can almost certainly
> produce whatever style Qt wants, which is a claim clang-format most
> certainly can't make.
> (Besides, for me, the whole reflow thing was sort of a deal-killer.)
> BTW, does clang-format know how to correctly style old-style SIGNALS/SLOTS?
> --
> Matthew
> _______________________________________________
> Development mailing list
> Development at lists.qt-project.org
> https://lists.qt-project.org/listinfo/development

More information about the Development mailing list