[Development] Upgrading the sources to C++11 keywords (Q_NULLPTR, etc.)

Marc Mutz marc.mutz at kdab.com
Thu Jul 23 19:22:46 CEST 2015


On Thursday 23 July 2015 15:47:10 Knoll Lars wrote:
> On 23/07/15 14:23, "Marc Mutz" <marc.mutz at kdab.com> wrote:
> >On Thursday 08 January 2015 23:33:34 Thiago Macieira wrote:
> >>  * Q_NULLPTR - strongly encouraged
> >
> >Ok, trying to summarize the discussion so we can move forward.
> >
> >There's a bug report (https://bugreports.qt.io/browse/QTBUG-45291) about
> >Qt
> >headers not compiling with -Wzero-as-null-pointer-constant, sometimes not
> >even
> >when locking the Qt headers away behind an -isystem. I understood the
> >discussion in this thread as follows:
> >
> >- ok to use Q_NULLPTR in public headers (the bug report suggests that this
> >
> >  should actually be enforced by headersclean).
> >
> >- ok to use in new code or as a drive-by iff the 0 isn't immediately
> >visible
> >
> >  as a nullptr. Example:
> >       validator(0), // Q_NULLPTR ok here
> >  
> >  Counter-example:
> >       const char *msg = 0 // Q_NULLPTR not wanted here
> >
> >- otherwise, we don't want Q_NULLPTR. We're waiting until we can move
> >directly
> >
> >  to nullptr. In particular, we cannot use Q_NULLPTR for its potentially
> >  disambiguating characteristics, until we require C++11 nullptr. So code
> >
> >must
> >
> >  still compile (modulo warnings) (and have the same meaning) if the
> >
> >Q_NULLPTR
> >
> >  is replaced back to 0.
> >
> >Consensus?
> 
> Mostly. But it looks like VS 2012 support nullptr, so I’d say we wait for
> 5.6 to be branched. After that we should globally get rid of Q_NULLPTR.
> i.e. Do a search and replace Q_NULLPTR -> nullptr in our code base. Then
> IMO the first two rules above should be taken into use with
> s/Q_NULLPTR/nullptr/.

I believe we should strive to have the LTS release warning-free in this 
regard. It's going to be in use for a long time, and the demand for nullptr-
correctness will only grow with time.

Otherwise, I agree.

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list