I have a large codebase that uses a number of unsafe functions, such as gmtime and strtok. Rather than trying to search through the codebase and replace these wholesale, I would like to make the compiler emit a warning or error when it sees them (to highlight the problem to maintenance developers). Is this possible with GCC?
I already know about __attribute__((deprecated)), but AFAIK I can’t use it since I don’t have control of the header files where these functions are declared.
Create a custom header
deprecated.h. In there, create your own wrapper functions,deprecated_strtok()etcetera that merely callstrtok. Mark those with__attribute__((deprecated)). Below those definitions,#define strtok deprecated_strtok. Finally, use-include deprecated.h