Click here to Skip to main content
15,885,985 members
Articles / Programming Languages / C++
Article

Find Orphaned Resource Constants

Rate me:
Please Sign up or sign in to vote.
3.50/5 (4 votes)
6 Feb 20041 min read 45.8K   185   10   10
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


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralOrphans.txt or new resource.h Pin
Herbert Yu23-Sep-04 8:07
Herbert Yu23-Sep-04 8:07 
General_APS_3D_CONTROLS should not be here Pin
Herbert Yu23-Sep-04 8:05
Herbert Yu23-Sep-04 8:05 
I used this and find following in output Orphans.txt file:

_APS_3D_CONTROLS
_APS_NEXT_RESOURCE_VALUE
_APS_NEXT_COMMAND_VALUE
_APS_NEXT_CONTROL_VALUE
_APS_NEXT_SYMED_VALUE

This is not correct if you worked on any MFC generated application.


---
Herbert Yu
Are you sure the speed of computer industry is proper? Are you sure the software you released is a bug free one?
GeneralResorg Pin
Bart Duijndam24-Feb-04 10:12
sussBart Duijndam24-Feb-04 10:12 
QuestionWhere to install Perl from? Pin
David Crow11-Feb-04 10:20
David Crow11-Feb-04 10:20 
AnswerRe: Where to install Perl from? Pin
strtdusty11-Feb-04 17:30
strtdusty11-Feb-04 17:30 
GeneralTry this Pin
John Miller10-Feb-04 16:08
John Miller10-Feb-04 16:08 
GeneralRe: Try this Pin
strtdusty11-Feb-04 17:32
strtdusty11-Feb-04 17:32 
GeneralRe: Try this Pin
John Miller12-Feb-04 4:28
John Miller12-Feb-04 4:28 
GeneralWinTransRC.com Pin
Uwe Keim8-Feb-04 19:31
sitebuilderUwe Keim8-Feb-04 19:31 
GeneralRe: WinTransRC.com Pin
Phil J Pearson10-Feb-04 8:24
Phil J Pearson10-Feb-04 8:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.