tool to find .h dependencies in C++
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > tool to find .h dependencies in C++




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    tool to find .h dependencies in C++  
Rares Vernica


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-27-07 06:18 AM

Hi,

I am working at a C++ project with many .h files. In the Makefile, for
each .cc file I need to list the .h files on which the .cc file depends
on so that it is recompiled whenever any of those changes.

What tool would you recommended for finding .h dependencies for a given
.cc file?

Thanks a lot,
Ray





[ Post a follow-up to this message ]



    Re: tool to find .h dependencies in C++  
Alexander Pazdnikov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-27-07 06:18 AM

Hi, Ray


$(CPP) $(INC_DIR) -MM -MF "$(DEPDIR)/$*.dep" -c $<

g++ -I./includes -I./headers -MM -MF myclass.dep -c myclass.cpp

It's really easy to make target in Makefile to produce dependecies
files for each *.cpp
As example

.PHONY : dep
DEPS=$(SRCS:.cpp=.dep)

dep: $(DEPS)

%.dep : %.cpp
$(CPP) $(INC_DIR) -MM -MF "$(DEPDIR)/$*.dep" -c $<

And include your depences files into Makefile

sinclude $(DEPDIR)/*.dep

Good Day
--
Alexander Pazdnikov






[ Post a follow-up to this message ]



    Re: tool to find .h dependencies in C++  
Logan Shaw


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-27-07 06:18 AM

Rares Vernica wrote:
> I am working at a C++ project with many .h files. In the Makefile, for
> each .cc file I need to list the .h files on which the .cc file depends
> on so that it is recompiled whenever any of those changes.
>
> What tool would you recommended for finding .h dependencies for a given
> .cc file?

How about :

$ whatis makedepend
makedepend (1x)      - create dependencies in makefiles
$

I believe it's originally intended for C programs, but this is really
a C preprocessor matter, not a compiler issue, so I think in this case
what works for C will work for C++.  Hmm, except that makedepend may
have difficulty with stuff like "#include <iostream>" (i.e. the missing
".h").

- Logan





[ Post a follow-up to this message ]



    Re: tool to find .h dependencies in C++  
Ralf Fassel


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-27-07 12:16 PM

* Logan Shaw <lshaw-usenet@austin.rr.com>
| Hmm, except that makedepend may have difficulty with stuff like
| "#include <iostream>" (i.e. the missing ".h").

There is no missing .h, the file is indeed called 'iostream', without
any extension.  But makedepend has indeed problems locating all of the
c++ include files, you need a bunch of -I directives.  Better let the
compiler do the job...

R'





[ Post a follow-up to this message ]



    Re: tool to find .h dependencies in C++  
Rares Vernica


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-27-07 06:19 PM

Ralf Fassel wrote:
> * Logan Shaw <lshaw-usenet@austin.rr.com>
> | Hmm, except that makedepend may have difficulty with stuff like
> | "#include <iostream>" (i.e. the missing ".h").
>
> There is no missing .h, the file is indeed called 'iostream', without
> any extension.  But makedepend has indeed problems locating all of the
> c++ include files, you need a bunch of -I directives.  Better let the
> compiler do the job...
>
> R'

Thanks a lot folks,

Ray





[ Post a follow-up to this message ]



    Re: tool to find .h dependencies in C++  
Walt Fles


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-28-07 06:18 PM

On Mar 27, 4:21 am, Ralf Fassel <ralf...@gmx.de> wrote:
> * Logan Shaw <lshaw-use...@austin.rr.com>
> | Hmm, except that makedepend may have difficulty with stuff like
> | "#include <iostream>" (i.e. the missing ".h").
>
> There is no missing .h, the file is indeed called 'iostream', without
> any extension.  But makedepend has indeed problems locating all of the
> c++ include files, you need a bunch of -I directives.  Better let the
> compiler do the job...
>
> R'

Or use a make engine that supports finding these dependencies and
utilizes the dependency tree properly,
like Lucent's nmake, or the Open Source version from AT&T:
http://www.research.att.com/sw/download/






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:43 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register