Is there a way to mark methods / classes in C ++ as deprecated?
In C # you can write:
[Obsolete("You shouldn't use this method anymore.")] void foo() {}
I use the GNU toolchain / Eclipse CDT, if that matters.
The easiest way is with #define DEPRECATED. In GCC, it expands to __attribute__((deprecated)), in Visual C ++, it expands to __declspec(deprecated), and in compilers that don't have something silymar, it expands to nothing.
#define DEPRECATED
__attribute__((deprecated))
__declspec(deprecated)
Only using compiler dependent pragmas: see the documentation
int old_fn () __attribute__ ((deprecated));
I do not know about the C ++ version that you are using, but Microsoft Visual C ++ has an outdated pragma . Your version may have something similar.
The C ++ 17 standard now provides this function: https://en.cppreference.com/w/cpp/language/attributes/deprecated
[[deprecated]] void F(); [[deprecated("reason")]] void G(); class [[deprecated]] H { /*...*/ };
Source: https://habr.com/ru/post/1707893/More articles:How do you resolve URN? - xmlException Standardization Guidelines - javaIs there a dojo or jQuery only for Firefox add to development? - javascriptHow to block asp.net page from multi-user editing? - c #How to insert image and text in asp: Menu control - asp.netRegex соответствует имени хоста - не включая TLD - regexCommand line cd option (change directory) in c #? - command-lineWhat is the best way to create a Java servlet or JSP that does not necessarily include content depending on URL parameters - javaSignature Storage Ethics - storageFinding days of the week in a date range using oracle SQL - sqlAll Articles