Version-based deprecation macros for KDE Frameworks API: execution plan

Friedrich W. H. Kossebau kossebau at kde.org
Fri Oct 4 16:37:12 BST 2019


Hi,

for those who missed things so far, quick recap first:

To better assist users of KDE Frameworks in dealing with its deprecated API, 
we might want to give them more control over visibility of such API to the 
compiler when building their software or if deprecation warnings are emitted.

For some weeks there has been work on a cmake-based technique which uses the 
usually already present generated export macros header (e.g. foo_export.h) as 
injector for new respective C++ prepocessor macros which enable to mark 
deprecated API like this:

#if FOO_ENABLE_DEPRECATED_SINCE(5, 0)
/**
 * @deprecated Since 5.0. Use bar(). // Sadly doxygen needs data duplicated
 */
FOO_DEPRECATED_VERSION(5, 0, "Use bar()")
void foo();
#endif

Which then allows users of the API to control visibility or warnings by macro 
flags like
-DFOO_DISABLE_DEPRECATED_BEFORE_AND_AT=0xXYZ
-DFOO_DEPRECATED_WARNINGS_SINCE=0xXYZ
-DFOO_NO_DEPRECATED (short for:FOO_DISABLE_DEPRECATED_BEFORE_AND_AT=latest)
-DFOO_NO_DEPRECATED_WARNINGS (short for: FOO_DEPRECATED_WARNINGS_SINCE=0)
similar to what we know from Qt.

Next to that, the developed solution also supports:
* optional group default flags, so users can easily control settings for
  groups of libraries (like all the KDE Frameworks)
* disabling build of implementation code of deprecated API (like useful for
  bundled shared libraries)

This solution is ECMGenerateExportHeader, up for review process at
    https://phabricator.kde.org/D23789

There are also patches for two KDE Frameworks modules as examples:
    KCoreAddons: https://phabricator.kde.org/D23800
    KService: https://phabricator.kde.org/D23802

See also related blog post for some more details:
https://frinring.wordpress.com/2019/09/09/more-control-over-warnings-for-and-visibility-of-deprecated-library-api-via-generated-export-macro-header/

Cheers
Friedrich




More information about the Kde-frameworks-devel mailing list