[Development] Compiler warnings

Smith Martin Martin.Smith at theqtcompany.com
Thu Oct 16 20:48:34 CEST 2014


But if lack of a parameter name means unused (by choice) parameter, then compilers shouldn't warn that it is an unused parameter.

martin
________________________________________
From: development-bounces+martin.smith=theqtcompany.com at qt-project.org <development-bounces+martin.smith=theqtcompany.com at qt-project.org> on behalf of Kevin Kofler <kevin.kofler at chello.at>
Sent: Thursday, October 16, 2014 7:46 PM
To: development at qt-project.org
Subject: Re: [Development] Compiler warnings

Smith Martin wrote:
> But maintaining binary compatibility is now a necessary facet of software
> engineering, so maybe it is time for the C++ standard to support it. A
> keyword could be added to the parameter declaration, "compatibility" or
> "placeholder" for example, could precede a parameter declaration that is
> kept for binary compatibility. The compiler would not warn that the
> parameter was not used.

The lack of a name for the parameter is already how the C++ standard
specifies unused parameters, and g++ normally does NOT warn in that case.

In addition, GCC/g++ has supported __attribute__((unused)) for ages. For Qt
code, there's also the Q_UNUSED macro, which is used in the function itself,
and which should work with most (if not all) compilers out there. But all
those should not be needed in cases where you can simply omit the parameter
name.

        Kevin Kofler

_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list