I would like to mark certain elements, functions and classes as deprecated, so that the compiler generates a warning.
My intention is to modernize certain aspects of the source. Especially when focusing on more platform independence.
E.g. By marking the WinAPI and special Windows classes (such as TRegistry) as “deprecated” they could be replaced or at least moved and made platform independent.
As for the language elements, I would especially like to deprecate the with, label and goto keywords.
I already tried to generate a warning for functions and classes by inserting a {$IF DECLARED(...)}{$MESSAGE WARN...} into the bottom of the unit file, but this will evidently fail with the core units…
Does somebody know a Tool that does this?
As an alternative to warnings, you could go with a simple app that parses all source code and reports the use of these constructs.
With a little investigation, I’m sure you can find some static code analysis tools that will even go a bit further and alert you to certain code-smells. (E.g. incorrect use of try..finally, swallowed exceptions).
Plug the app or the static code analyser in as a step in your build process, and you have the equivalent to compile-time warnings.