Heads-up for developers using KF modules: how to disable visibility of & warnings about deprecated API for >= 5.64
Friedrich W. H. Kossebau
kossebau at kde.org
Mon Oct 21 14:44:36 BST 2019
tldr; Please test now with git master the new available C++ macros with KF
as well as individual specializations per library, e.g.
so issues can be catched before the 5.64 release.
Last WE git master of all KDE Frameworks has seen the completion of the
introduction of a new feature which allows developers building against KDE
Frameworks libraries to control which of its deprecated API is visible to the
compiler as well as for which versions deprecation warnings should be emitted.
You are invited or rather encouraged to give this a testing now already, so
issues can be catched before this gets released in then KF 5.64.
Without any settings, you will get warnings when using deprecated API, any
deprecated API is visible to your build.
To just get rid of any warnings, use (with CMake, also ff.)
To just hide any deprecated API to your build, use
To disable warnings about API deprecated first after a given version or, in
other words, only see warnings for API deprecated first in versions up to and
including a given, use (example: 5.28.0)
add_definitions(-DKF_DEPRECATED_WARNINGS_SINCE=0x051C00) # 5.28.0
To hide deprecated API up to and including a certain version (e.g. the minimal
KF version you support), use (example: 5.28.0)
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x051C00) # 5.28.0
This also sets the default of KF_DEPRECATED_WARNINGS_SINCE to that version,
so you will not see any warnings for API deprecated in newer versions, unless
setting another version explicitly for that.
Next to these KDE Frameworks wide settings, one can also override them for
individual libraries, using macros with a prefix matching the library name.
E.g. to override for KCoreAddons the version at and before which deprecated
API is made invisible to the compiler, one does this (order is not relevant):
-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x051C00 # 5.28.0
The names here are following the similar macros introduced with Qt 5.13, cmp
https://doc.qt.io/qt-5/qtglobal.html#QT_DISABLE_DEPRECATED_BEFORE , so one can
apply known approaches. Just using BEFORE_AND_AT, because BEFORE is not really
QT_DEPRECATED_WARNINGS_SINCE also exists, with same default mechanism for API
with a versioned deprecation macro used (only used with newer deprecated Qt
API it seems), but so far had not been publically documented yet (cite: "Just
forgot it (and also the reviewers) I would guess. There is no plan to change
it, at least none I'm aware of.")
More information about the kde-core-devel