Issue Warning for Deprecated Library Function

Hi. I'm working on updating one of my libraries. I will be deprecating certain functions and will remove them in the future.

Are there any slick preprocessor macros or compiler directives that I can add to the source code so that a warning will be thrown should user code attempt to invoke one of these deprecated (and soon-to-be-removed) functions?

Thanks.

Here you go:
https://en.cppreference.com/w/cpp/language/attributes/deprecated

This is a relatively recent advancement so it's possible that not all toolchains will support it. You might check this code used to deprecate the Arduino binary macros:

(but note the waters are a bit muddied there because it also needs to check for the standard versions that have binary literals and deprecated enums.

At least for gcc/g++: attribute ((deprecated))

Perfect. Works well at least for ESP32 toolchain. Will try others. Thanks.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.