Skip to main content
Email Password   helpLost your password?

Introduction

I've seen many people ask about utilities to view the tree of #included files in their source code. I think I've seen one of these before, either here at CodeProject or maybe at CodeGuru, but I can't seem to find it. Since I really enjoy text processing, I took it upon myself to write my own. What I've come up with is a fast, multi-threaded #include tree generator.

Features

Searching multiple directories

As you can see in the screenshot above, there are a few fields to fill in before you can generate the tree. I think it's pretty self-explanatory, but I will explain the fields here just in case some think it's not.

Searching files loaded from VC6/VC7 workspaces or projects

When searching a workspace or project, you don't have to input as much information as when searching a directory, but you still have to load a project or workspace, specify a file mask, and select a configuration. The software will read settings related to preprocessing, such as additional include directories, and preprocessor definitions. Also, the VC6 project reader will read the registry for the VC6 include directories, and the VC7 project reader will read the registry for the VC7 include directories, which means if you have VC6 or VC7 configured already, you don't have to configure this program as well.

Note: The workspace and project loading isn't perfect yet, but I have tested it in a variety of scenarios, and it works well for me. The biggest problem is accurately interpreting the project settings, which there are still issues with.

Other options

Once you've entered some valid data, click Start and the program will start the search. The searching is done in a separate thread, so you will see the button's text turn to "Stop" once you click Start. To stop the search, simply click Stop and the thread will quit, turning the Stop button back into the Start button.

Viewing and searching the output

The output is shown in a standard Win32 tree control, using MFC's CTreeCtrl. As each source file is completed, the program populates the tree with the source file and all the files #included by it. You will notice that there are a few icons used in the tree that denote properties of the item. Here's an explanation of them:

This icon is used to denote a regular file.

This icon is used to denote that the instance of the file is not the first time it was included by the current source file (either directly or indirectly).

This icon is used to denote that the file could not be found along the specified include paths.

This icon is used to denote that the file has been recursively included.

To search the tree for a particular file, select the Find... menu item, or click F3 to search for the next occurrence of a string.

Saving and restoring the data

If you click on the Save toolbar icon, or select the Save Results... menu item, you will be prompted to enter a file name to save to. The results are saved in XML format like the sample shown below.

Sample XML output (viewed with IE)

Once you have saved an XML file, you can click the Open toolbar icon, or select the Open... menu item to select a file to reload. The XML tree will be reloaded into the Include Finder.

About the code

Note: At my work we have a coding standard which is a form of Hungarian notation. I've also used this standard in this project. It's what I've been using for the past few years, and I like it, but that's not the point of the article or the code, so please don't flame me for it.

I've tried to keep the core code of the program as separated from the interface as possible, so that it will be easy for someone to reuse the interesting portions. Since the code has grown substantially in size since the first version, I decided to omit descriptions of the classes. If you are interested in using the code, you can find a description of what's in each file in the headers at the top of them.

Acknowledgements

I'd like to thank the following people:

To Do

History

  1. January 7th, 2003 - Initial release.
  2. January 27th, 2003
  3. February 24th, 2003 (bug fixes) - Thanks to Medved, Oliver Wahl, and Andreas Saurwin for alerting me to, and/or showing patches for these bugs.
  4. July 30th, 2003 (bug fixes and some changes to run on NT 4 without IE shell update)

Disclaimer and copyright

Although great care has gone into developing this software, it is provided without any guarantee of reliability, accuracy of information, or correctness of operation. I am not responsible for any damages that may occur as a result of using this software. Use this software entirely at your own risk. Copyright 2003, Chris Richardson.

Final notes

Any feedback or bug reports will be greatly appreciated. If you do or do not like the article, the code, or the program I've provided, please tell me why.

Thanks for taking the time to read my article. I hope you enjoyed it, and I hope you find the Include Finder useful.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
Generallittle bug? What is the intention? Pin
peterchen
13:42 11 Nov '06  
GeneralRe: little bug? What is the intention? Pin
Chris Richardson
13:47 11 Nov '06  
GeneralRe: little bug? What is the intention? Pin
peterchen
14:06 11 Nov '06  
GeneralRe: little bug? What is the intention? Pin
Chris Richardson
14:14 11 Nov '06  
GeneralRe: little bug? What is the intention? Pin
peterchen
14:31 11 Nov '06  
NewsVisual Studio Addin Pin
Matt Godbolt
5:25 20 Sep '06  
GeneralRe: Visual Studio Addin [modified] Pin
peterchen
13:28 11 Nov '06  
GeneralRe: Visual Studio Addin Pin
Member 490724
13:25 30 Aug '08  
Generalfix/enhancement Pin
BillTT
5:07 28 Jul '06  
Generaldoxygen with graphviz do it better! Pin
Mihai Moga
2:03 6 Apr '06  
GeneralSuggested Enhancement Pin
Anonymous
1:57 6 Oct '05  
Generalstdafx.h Pin
FatalError0x4c
10:54 15 Dec '04  
GeneralReport #if settings around each file? Pin
SBarney
10:01 25 Oct '04  
GeneralScreen disappears. Pin
WREY
4:32 9 Sep '04  
GeneralRe: Screen disappears. Pin
Chris Richardson
8:46 10 Sep '04  
GeneralNo longer supported? Pin
.dan.g.
22:28 1 Apr '04  
GeneralRe: No longer supported? Pin
Chris Richardson
9:42 2 Apr '04  
GeneralNice work! Pin
xnwang22
11:10 18 Feb '04  
GeneralA couple of other suggestions Pin
MerlinB
23:26 30 Sep '03  
GeneralCould be more useful Pin
Robin
9:43 28 Aug '03  
Generalreproducible crash Pin
Robin
9:38 28 Aug '03  
Generalinclude path Pin
Alarik
2:38 6 Aug '03  
GeneralEVC Workspaces Pin
southpawjoe
5:38 5 Aug '03  
GeneralTool's try Pin
Eric Lapouge
2:23 31 Jul '03  
GeneralOther languages... Pin
Judd
23:13 30 Jul '03  


Last Updated 29 Jul 2003 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009