By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,935 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

How to determine which files are used in a c++ project

P: 1
I have a Visual Studio 2003 solution with multiple projects (3 C++, 2 C#, and 2 VB).
The code has been maintained and upgraded since VC 6.0 by several developers. There are litarally several hundred files in the solution (the majority in the C++ projects.)

I want to find out what files are REALLY used by the C++ projects. I know that the project file has a list of all files included in the specific project but I also know that I do not need every file that is listed.

1. Is there some type of compiler setting or program that I can run to determine which files are orphaned (or actively used) by a project? (primary task for me)

2. Is there a program that can determine which include files should not be used in each of my .cpp/.h files? (nice to do)

I have access to all the MS Visual Studio version starting with 6.0 and including 2008 beta and I am not afraid to use other tools (even *nix tools) :D

Thanks in advanced,
Aug 9 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
There are several way to proceed.

Method A:
Create a new project and add the file with main(), or the equivalent.
Fix the first error by adding the correct file.
Repeat untilk you have a error free build.

Method B:
Remove a file from the project and rebuild.
If no errors, that file is not required.
Repeat by removing each file to see what happens.

Header files, of course, are not part of the project necessarily since they are included by the preprocessor. To locate unneeded headers, you need to locate the header and rename it. Then create a new empty header with the original name and rebuild.

If there are no errors, then that header was not required.

Be sure you do not alter any of the header files that were installed with the compiler.

As long as you are careful and keep aaccurate accounting of what you have done, then you should be able to accomplish this.
Aug 10 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.