Defining obsolete functions in C ++

In a C ++ project documented with Doxygen, I marked some functions as \ deprecated in Doxygen comments. Is there a way to use these comments (with Doxygen or another tool) to detect that another function that does not support obsolescence is causing obsolete? (The project is quite large, and it will take a lot of time through all classes).

thanks

+4
source share
2 answers

If you use GCC or clang to compile the code, you can manually annotate the functions.

__attribute__((__deprecated__)) void dep_fun() { } 

Then calling dep_fun anywhere in your code will produce a diagnostic message.

If you placed the doxygen \deprecated annotation sequentially, you should be able to automatically update the code using tools such as sed.

+9
source

Based on Benjamin's answer: Some useful compiler directives:

 #ifdef _MSC_VER #define DEPRECATED __declspec(deprecated) #elif defined(__GNUC__) | defined(__clang__) #define DEPRECATED __attribute__((__deprecated__)) #else #define DEPRECATED #endif //usage: DEPRECATED void foo(int bar); 

(warning: unchecked under clang and msc, checked only on GNUC.)

+3
source

Source: https://habr.com/ru/post/1439153/


All Articles