FInding unused variables

Has anyone written a utility that will find unused variables in a source file? The compile does find those that are defined, but if it is used in a conditional statement block, it still treats it as unused.

I use Sloeber in Eclipse and get this for free… and a variable used in a conditional is considered used. Furthermore, this distinguishes between unwritten and unused.

I can understand your hope for a utility but I don’t have one. Sorry!

Turn on full reporting of the compilation in the IDE and it will show you unused local variables but not globals in the output

you can define global variables as static and the compiler warns about unused static variables

If I think a variable might be unused I comment it out and compile the code; the compiler will object if the variable is needed somewhere.

Maybe a version of lint.