Consensus on the kdelibs coding style

Thiago Macieira thiago at
Sat Jul 5 15:13:33 BST 2008

Lubos Lunak wrote:
>which defines even completely useless things like
>requiring {}'s around a single-line if() body statement (where's the
> point in that?), I'd prefer something simple.

Just for information, that requirement is not in the Qt style. That's 
actually one of modifications that was added to the KDE Libs style on top 
of the Qt style. If you look at Qt code, you'll see that is not used.

Anyways, regarding your proposal, I'll say what most other people will 
say: I disagree in certain points, but having one *single* style is 
better than having none, whatever the style is (as long as it makes 
sense, of course).

The major point is actually deciding on the "4 spaces, NO TABS" 
(capitalisation mine, but should be there). Tabs are inherently evil and 
should be banned altogether, to the point of warranting a wide-reaching 
tab-replacement commit (svn can now ignore whitespace changes in 
annotation, git has been able to do it for years).

A distant second is the placement of the braces. Your style is closer to 
my own preferred style, actually, but I'd still advocate for matching 
Qt's simply because of pragmatism.

The only thing I don't like in your code is the indentation of label-like 
constructs (case labels and public/protected/private) because of this:

class Foo
        Foo( int a );

So I'd go for "label-like constructs are de-indented one level":

switch (a)
case 'a':

This would again match the Qt style.

So, that's it. As long as we can agree on one style and actually enforce 
it, I'll be happy.

  Thiago Macieira  -  thiago (AT) - thiago (AT)
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list