Enable deprecation warnings by default

With Qt 6 in sight, people need to start moving away from
their deprecated APIs, as we want to remove them all in 6.0.
We are marking deprecated APIs with deprecation attributes,
but by default we're disabling deprecation warnings, making
them an opt-in by the user.

We need to do the opposite: make deprecation warnings enabled
by default, and have an opt-out define.

[ChangeLog][QtCore][Important Behavior Changes] Qt now
enables by default warnings when using APIs marked as
deprecated. It is possible to disable such warnings by
defining the QT_NO_DEPRECATED_WARNINGS macro. The old
QT_DEPRECATED_WARNINGS macro which was used to enable
this warning now has no effect (warnings are automatically
enabled).

Task-number: QTBUG-73048
Change-Id: Ie2b024fd667eb876b6ac9054cbbbc5a455cb9d5c
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Giuseppe D'Angelo 2019-01-29 12:09:22 +01:00
parent 2bc362c9fa
commit 7847e6bc02
3 changed files with 23 additions and 15 deletions

View File

@ -345,14 +345,10 @@ ProjectGenerator::writeMakefile(QTextStream &t)
<< getWritableVar("CONFIG_REMOVE", false)
<< getWritableVar("INCLUDEPATH") << endl;
t << "# The following define makes your compiler warn you if you use any\n"
"# feature of Qt which has been marked as deprecated (the exact warnings\n"
"# depend on your compiler). Please consult the documentation of the\n"
"# deprecated API in order to know how to port your code away from it.\n"
"DEFINES += QT_DEPRECATED_WARNINGS\n"
"\n"
"# You can also make your code fail to compile if you use deprecated APIs.\n"
t << "# You can make your code fail to compile if you use deprecated APIs.\n"
"# In order to do so, uncomment the following line.\n"
"# Please consult the documentation of the deprecated API in order to know\n"
"# how to port your code away from it.\n"
"# You can also select to disable deprecated APIs only up to a certain version of Qt.\n"
"#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0\n\n";

View File

@ -1979,11 +1979,11 @@ bool qSharedBuild() Q_DECL_NOTHROW
a specified version of Qt or any earlier version. The default version number is 5.0,
meaning that functions deprecated in or before Qt 5.0 will not be included.
Examples:
When using a future release of Qt 5, set QT_DISABLE_DEPRECATED_BEFORE=0x050100 to
disable functions deprecated in Qt 5.1 and earlier. In any release, set
QT_DISABLE_DEPRECATED_BEFORE=0x000000 to enable any functions, including the ones
deprecated in Qt 5.0
For instance, when using a future release of Qt 5, set
\c{QT_DISABLE_DEPRECATED_BEFORE=0x050100} to disable functions deprecated in
Qt 5.1 and earlier. In any release, set
\c{QT_DISABLE_DEPRECATED_BEFORE=0x000000} to enable all functions, including
the ones deprecated in Qt 5.0.
\sa QT_DEPRECATED_WARNINGS
*/
@ -1993,12 +1993,24 @@ bool qSharedBuild() Q_DECL_NOTHROW
\macro QT_DEPRECATED_WARNINGS
\relates <QtGlobal>
If this macro is defined, the compiler will generate warnings if API declared as
Since Qt 5.13, this macro has no effect. In Qt 5.12 and before, if this macro
is defined, the compiler will generate warnings if any API declared as
deprecated by Qt is used.
\sa QT_DISABLE_DEPRECATED_BEFORE
\sa QT_DISABLE_DEPRECATED_BEFORE, QT_NO_DEPRECATED_WARNINGS
*/
/*!
\macro QT_NO_DEPRECATED_WARNINGS
\relates <QtGlobal>
\since 5.13
This macro can be used to suppress deprecation warnings that would otherwise
be generated when using deprecated APIs.
\sa QT_DISABLE_DEPRECATED_BEFORE
*/
#if defined(QT_BUILD_QMAKE)
// needed to bootstrap qmake
static const unsigned int qt_one = 1;

View File

@ -287,7 +287,7 @@ typedef double qreal;
# undef QT_DEPRECATED_X
# undef QT_DEPRECATED_VARIABLE
# undef QT_DEPRECATED_CONSTRUCTOR
#elif defined(QT_DEPRECATED_WARNINGS)
#elif !defined(QT_NO_DEPRECATED_WARNINGS)
# undef QT_DEPRECATED
# define QT_DEPRECATED Q_DECL_DEPRECATED
# undef QT_DEPRECATED_X