[Development] commas in ctor-init-lists
Christian Kandeler
christian.kandeler at qt.io
Fri Jun 3 15:59:34 CEST 2016
On 06/03/2016 02:52 PM, Thiago Macieira wrote:
> I've seen a lot of code do:
>
> #ifdef FOO
> if (foo) {
> // something
> } else
> #endif
> if (bar) {
> // something else
> } else {
> // default
> }
This kind of thing is an abomination that should never ever be allowed,
regardless of other coding style considerations. You can hardly even
tell whether the code is syntactically correct in both cases, let alone
semantics.
Factor out ifdefs into dedicated functions whenever possible. You'll be
glad you did, and even more so the people who have to read your code later.
Christian
More information about the Development
mailing list