Finding Header dependencies

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm currently using MSVC.Net 2003. My task is to extract header dependencies
from C++ source code. To that end, I invoke "cl /E" and parse the
preprocessor output. While this approach is effective, it is quite slow.
The runtime of this command is so similar to actually compiling a file that
I'm guessing it really is compiled even though no output is created. Can
anyone answer a few questions about how cl performs preprocessing?

1) Are there any command line switches I should add or avoid in order to
reduce cl's work to the bare minimum required for preprocessing?

2) Would the pre-processing performance improve if I switched to VC 2005?

3) Is there some other tool or method that would give me this information in
a more efficient manner?

Thanks for your time,
Justin
 
Justin T. Gibbs said:
I'm currently using MSVC.Net 2003. My task is to extract header
dependencies
from C++ source code. To that end, I invoke "cl /E" and parse the
preprocessor output. While this approach is effective, it is quite slow.
The runtime of this command is so similar to actually compiling a file
that
I'm guessing it really is compiled even though no output is created. Can
anyone answer a few questions about how cl performs preprocessing?

1) Are there any command line switches I should add or avoid in order to
reduce cl's work to the bare minimum required for preprocessing?

2) Would the pre-processing performance improve if I switched to VC 2005?

3) Is there some other tool or method that would give me this information
in
a more efficient manner?

gcc -MMD
or
makedep http://sourceforge.net/projects/makedep
 
gcc -MMD

Yes, gcc would be much faster, but gcc doesn't have all of the built in
preprocessor definitions that cl has- definitions that may impact the headers
that are included. I could perform an analysis to on what flags are defined
for which options, and carefully pass those to gcc, but that would make my
solution much more difficult to maintain.
 
Back
Top