[Development] commas in ctor-init-lists

Scott Aron Bloom scott at towel42.com
Wed Jun 1 19:05:39 CEST 2016


In previous projects I have worked on, the "leading comma" was done because it makes it easier if you have #ifdef'ed variables that need initialization.

You are less likely to introduce a syntax error when the defined variable is not set..

Ie, the first one causes a syntax error
QFoo::QFoo()
  : QBase(),
    m_f1(),
#ifdef USE_F2
    m_f2()
#endif
{

}

Whereas the second does not

QFoo::QFoo()
  : QBase()
  , m_f1()
#ifdef USE_F2
  , m_f2()
#endif
{

}


-----Original Message-----
From: Development [mailto:development-bounces+scott=towel42.com at qt-project.org] On Behalf Of Marc Mutz
Sent: Wednesday, June 1, 2016 5:42 AM
To: development at qt-project.org
Subject: [Development] commas in ctor-init-lists

Hi,

There seems to have been a silent underground move to uglify the Qt sources , by using commas to introduce lines . I have no idea where this came from , but it looks butt -ugly and it is in violation of http ://wiki .qt .io /Qt_Coding_Style

QFoo::QFoo()
  : QBase(),
    m_f1(),
    m_f2()
{

}

-not-

QFoo::QFoo()
  : QBase()
  , m_f1()
  , m_f2()
{

}

(http://wiki.qt.io/Qt_Coding_Style#Line_breaks 2nd item: "Commas go at the _end_ of wrapped lines")

Thanks,
Marc

--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - Qt, C++ and OpenGL Experts
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list