ea4k / klog

KLog is a multiplatform free hamradio logger. It runs natively on Linux, macOS and Windows.
https://www.klog.xyz
GNU General Public License v3.0
76 stars 25 forks source link

Define a KLOG_DEPRECATED macro? #630

Closed ikbenkous closed 8 months ago

ikbenkous commented 1 year ago

How can one mark a function as deprecated?

C++14 and later has a [[deprecated]] attribute, but klog is compiled with -std=gnu++11.

What about the following in global.h?

// If C++14
#if __cplusplus >= 201309L
    // use modern deprecation feature
    #define KLOG_DEPRECATED [[deprecated]]
#else
    //... no idea how to handle this, but this seems overly noisy?
    #define KLOG_DEPRECATED
    #warning "KLOG_DEPRECATED is not defined yet!"
#endif

One can then mark a function as deprecated as follows:

KLOG_DEPRECATED bool isSameFreq(const double fr1, const double fr2);

Thoughts?

ea4k commented 1 year ago

Why should we mark as deprecated instead of simply removing it?

ikbenkous commented 1 year ago

Having a way to mark functions as 'deprecated' allows us to keep functions around yet signal to others: do not build on this! It's a nice feature to have to improve collaboration.

For instance: the isSameFreq() should probably be deprecated when the Frequency class is finally implemented. Implementing that class is the easy part. Upgrading the code to use that new class might take a while. Hence: the ability to mark isSameFreq() as 'deprecated' during that transition period is a smart thing to do.

I'm sure there are (and will be in the future) plenty of cases where deprecating something until someone gets around to remove/rewrite is just a really nice enhancement!

A KLOG_DEPRECATED macro or some other way(!!!) of deprecating things must be language version agnostic. It should not use language features not available in C++11 until the language version is upgraded.

ea4k commented 9 months ago

It really makes sense. Let's work on it.

ea4k commented 8 months ago

I have added your code to global.h and tested against DataProxy_SQLite::getBands() which is really a deprecated function. It seems to work. More tests is recommended.

Captura de pantalla 2024-03-26 a las 23 03 58