Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define a KLOG_DEPRECATED macro? #630

Closed
ikbenkous opened this issue Sep 29, 2023 · 4 comments
Closed

Define a KLOG_DEPRECATED macro? #630

ikbenkous opened this issue Sep 29, 2023 · 4 comments
Labels
enhancement New feature or request question Further information is requested
Milestone

Comments

@ikbenkous
Copy link
Contributor

ikbenkous commented Sep 29, 2023

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?

@ikbenkous ikbenkous changed the title Define KLOG_DEPRECATED macro? Define a KLOG_DEPRECATED macro? Sep 29, 2023
@ea4k
Copy link
Owner

ea4k commented Oct 19, 2023

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

@ea4k ea4k added the question Further information is requested label Oct 19, 2023
@ikbenkous
Copy link
Contributor Author

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 ea4k added the enhancement New feature or request label Feb 29, 2024
@ea4k ea4k added this to the KLog-2.4 milestone Feb 29, 2024
@ea4k
Copy link
Owner

ea4k commented Feb 29, 2024

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

@ea4k
Copy link
Owner

ea4k commented Mar 26, 2024

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

@ea4k ea4k closed this as completed Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants