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


Hi,

tldr; Please test now with git master the new available C++ macros with KF
-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0xXXYYZZ
-DKF_DEPRECATED_WARNINGS_SINCE=0xXYYZZ
-DKF_NO_DEPRECATED_WARNINGS
-DKF_NO_DEPRECATED
as well as individual specializations per library, e.g.
-DK{LIB}_DISABLE_DEPRECATED_BEFORE_AND_AT=0xXYYYZZ
-DK{LIB}_DEPRECATED_WARNINGS_SINCE=0xXXYYZZ
-DK{LIB}_NO_DEPRECATED_WARNINGS
-DK{LIB}_NO_DEPRECATED 
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.)
    add_definitions(-DKF_NO_DEPRECATED_WARNINGS)

To just hide any deprecated API to your build, use
    add_definitions(-DKF_NO_DEPRECATED)

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):
    add_definitions(
        -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x051C00 # 5.28.0
        -DKCOREADDONS_DISABLE_DEPRECATED_BEFORE_AND_AT=0x050000
    )

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 
correct ;)
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.")

Cheers
Friedrich






More information about the kde-core-devel mailing list