Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Find Orphaned Resource Constants

0.00/5 (No votes)
6 Feb 2004 1  
A Perl script to help locate #define's in your Resource.h file that are no longer referenced by your VS project.

Introduction

You may have noticed that when using Visual Studio 6.0's resource editor, it doesn't do a great job of keeping your resource files clean. If you delete a resource from the editor, it doesn't usually delete the associated #define in your resource.h. While this isn't a huge problem (unless you are running out of constants in the valid ranges), it has always bugged me. I wrote a Perl script which will look at your .dsp, parse though the associated source files, and try to match the constants defined in your Resource.h file. Any constants that are not matched will be written to an output file Orphans.txt.

To use:

  1. You must have Perl installed.
  2. Call using:
> Perl FindOrphanedResources.pl <full path to dsp> [<Resource.h file>="Resource.h"]

Possible problems: I realize that files not included in the DSP may be using the constants defined in the Resource file. Since I couldn't think of any good way to find all the files that #include (somewhere down the chain) the resource.h file, I stuck with just those in the DSP. You may want to verify that the constants identified are truly not being used by any files in your projects. This script will at least narrow down the list for you.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here