1

I'm working with a very old and large VC6++ project and it's all messed up. There are unused files and folders everywhere, copies of folders and it's just a mess to clean it up by hand in its current state.

It will be done eventually, but is there any simple way to check what files and folders are used when it does a clean compile?

The project settings doesnt help me at all because it simply uses copies of folders and additional include directories.

Any suggestions?

John
  • 13
  • 2
  • Under linux I would just build things and check the last accessed timestamp of the files, don't know if windows has anything similar. – PlasmaHH Sep 13 '11 at 09:06
  • Visual C++ 6? (/me check current date)... In 2011?... For your problem, remove everything but the DSW and DSP file, and try the compilation. For each error, put back the ONE file the compiler needs, and try again. In the end, you'll have only what is necessary for that project... – paercebal Sep 13 '11 at 09:15
  • this question is quite similar to http://stackoverflow.com/questions/1301850/tools-to-find-included-headers-which-are-unused – dip Sep 13 '11 at 09:19
  • So your application is likely to be up to over ten years old and based on a rather buggy implementation of the C++ language. Does it really still fit current requirements? Is it really not worth it to rewrite it? Still, I'm aware that putting the project back into a manageable state is likely to be an indispensable step to be able to make the above decisions. – Nicola Musatti Sep 13 '11 at 09:42

3 Answers3

2

Well, if you want to parse the compiler output you can get which files are actually used. I also find this when googling around, you might want to try (I haven't tried it myself). My way would be to clean the build, list all source files, build, and for each source find its corresponding .obj. The ones without .obj are not used. Note that this only works for source files, unused header files stay undetected.

LeleDumbo
  • 9,192
  • 4
  • 24
  • 38
  • 1
    Checking the obj-files seems like a good idea. But what about checking the last access date on the files? I thought about that and it should show what header files are used aswell. hmm. I might be missing something. – John Sep 13 '11 at 09:04
  • Start with the obj file method. It is simple and quick and it'll get rid of a good few of your obsoletes. – Dennis Sep 13 '11 at 09:41
1

VC6 will produce a makefile for you:

You can use the generated makefile (and the associated .dep file) as a starting point and edit it down to the list of files that get used in a build.

This will let you see the header files that the project depends on in addition to the .c/.cpp/.lib files that might show in the build log. One thing to keep in mind is that you'll probably also want to make sure you track the .dsw and .dsp workspace and project files.

If you're a bit adventurous, you might be able to convince the makefile to actually copy the source files to some other location for you with an appropriate override of the certain macros and/or dependencies. But that would probably be more trouble than it's worth for a one-time effort.

Finally, there's a commercial product, CopyWiz by Kinook Software, that seems to have features that might do what you're looking for (and it supports VC++ 6). Note: I'm not sure if it will do what you want, but it may be worth a look.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
  • I wrote a small tool that parsed the makefile and it's a superb solution. Thank you very much! – John Sep 14 '11 at 09:38
0

Yes. Run Process Monitor from SysInternals. It can capture all file system events and filter them based on the path and other factors.

So, set the filter to the root of your source tree, only succesfull file reads (VC looks for headers in many places), and build your project. You'll probably still see several thousand events. So, save them to file, sort by path, and remove duplicate paths (headers especially will have many duplicate entries)

MSalters
  • 173,980
  • 10
  • 155
  • 350