3
votes

Is there a possibility to make Delphi compiler display a warning for each constant that is defined but not used?

I am currently using Delphi 2006 and have several units full of resourcestrings, which are used throughout the project, and since the project is quite old, most of them aren't used anymore, although they remain in the units.

Alternatively I'm looking for a way to indicate such constants.

2
What about all of the constants defined in the VCL? I think you would get swamped with warnings if such a warning existed.Ian Goldby
IF such a warning existed, a way to identify constants in VCL might also exist, also i use prefixes in constant names, so even if i would get swamped it wouldn't be that hard to identify constants i would need.ertx

2 Answers

3
votes

Delphi has no features in the program that warn or indicate constants that are not used. It can do unused local variables or unused private fields, but not unused constants.

You need to look at one of the 3rd party static code analysis tools, e.g. Peganza Pascal Analyzer. However, I would not be surprised if there were no tools that reported what you want.

2
votes

The easiest way might be to comment out the resource strings, and then uncomment just those that are needed to make the code compile.