Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   isthere any tools that could help me check include dependency between c++ files? (http://www.velocityreviews.com/forums/t621989-isthere-any-tools-that-could-help-me-check-include-dependency-between-c-files-b-b.html)

thinktwice 06-24-2008 12:39 PM

isthere any tools that could help me check include dependency between c++ files?
 
sometimes project compile error just because incorrect include
relation between files. and it's a headache to check manually, i want
to know is there any tools could help me to do that?

thinktwice 06-24-2008 01:23 PM

Re: isthere any tools that could help me check include dependency between c++ files
 
thanks for you quick reply.

sometimes i meet the problem that compiles complains that it could not
recognize a class data type in a cpp file, but i'm sure i have
include the header file in this cpp file. i guess it might caused by
the mess include relation between files.



On 624, 901, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
> thinktwice wrote:
> > sometimes project compile error just because incorrect include
> > relation between files. and it's a headache to check manually, i want
> > to know is there any tools could help me to do that?

>
> What's the "incorrect include relation between files"? And how would
> you "check include dependency between C++ files"? Two C++ files are
> dependent if they include the same header? Or a C++ file is dependent
> on the header it includes? What exactly do you need to check?
>
> V
> --
> Please remove capital 'A's when replying by e-mail
> I do not respond to top-posted replies, please don't ask



Puppet_Sock 06-24-2008 01:30 PM

Re: isthere any tools that could help me check include dependency between c++ files
 
On Jun 24, 9:23*am, thinktwice <memorial...@gmail.com> wrote:
> sometimes i meet the problem that compiles complains that it could not
> recognize a class data type in a cpp file, *but i'm sure i have
> include the header file in this cpp file. i guess it might caused by
> the mess include relation between files.


Please don't top post.

Ok, "the mess include relation between files" does not sound
like a good thing. But it's hard to tell if that is what is
wrong. For example, are you sure your project includes the
cpp file that includes the implementation of the class?

It's very hard to diagnose your problem without seeing a
code example. But please read the FAQ about how to post
before you dump a huge blob of code into the newsgroup.
Socks

AnonMail2005@gmail.com 06-24-2008 01:34 PM

Re: isthere any tools that could help me check include dependency between c++ files?
 
On Jun 24, 8:39*am, thinktwice <memorial...@gmail.com> wrote:
> sometimes project compile error just because incorrect include
> relation between files. and it's a headache to check manually, i want
> to know is there any tools could help me to do that?

Doxygen can easily generate include file dependencies diagrams.

HTH

ManicQin 06-25-2008 10:14 AM

Re: isthere any tools that could help me check include dependency between c++ files
 
On Jun 24, 9:23 pm, thinktwice <memorial...@gmail.com> wrote:
> thanks for you quick reply.
>
> sometimes i meet the problem that compiles complains that it could not
> recognize a class data type in a cpp file, but i'm sure i have
> include the header file in this cpp file. i guess it might caused by
> the mess include relation between files.
>
> On 624, 901, Victor Bazarov <v.Abaza....@comAcast.net> wrote:
>
> > thinktwice wrote:
> > > sometimes project compile error just because incorrect include
> > > relation between files. and it's a headache to check manually, i want
> > > to know is there any tools could help me to do that?

>
> > What's the "incorrect include relation between files"? And how would
> > you "check include dependency between C++ files"? Two C++ files are
> > dependent if they include the same header? Or a C++ file is dependent
> > on the header it includes? What exactly do you need to check?

>
> > V
> > --
> > Please remove capital 'A's when replying by e-mail
> > I do not respond to top-posted replies, please don't ask

>
>


Do you use pre-compile headers?
And most important, do you include the same headers in your pre-
compiled and non pre compiled headers?

Juha Nieminen 06-26-2008 10:11 AM

Re: isthere any tools that could help me check include dependency between c++ files?
 
thinktwice wrote:
> sometimes project compile error just because incorrect include
> relation between files. and it's a headache to check manually, i want
> to know is there any tools could help me to do that?


You don't specify your platform nor the compiler you are using, which
makes answering your question very difficult.

I'll assume you are using gcc (or one of its ported variants) because
that's about the only one where there are no project files per se (but
instead makefiles are used).

gcc itself can be used to generate a Makefile-compatible file
dependency listing, like this:

gcc -MM <source files here>

(You don't have to specify header files there.)

If you are writing a Makefile, you can automatize that. This is a
Makefile I use to quickly build small projects, with all the
dependencies automatically calculated. Note that if the dependencies
change, you'll need to delete the .dep file so that it will be
recreated. (Also note that it requires GNU make to work):

#----------------------------------------------------------------
# List source files (not headers!) and binary name:
SOURCES=$(wildcard *.cc)
BINARY=programname

# Set up compiler and compiler options:
CXX=g++
CXXFLAGS=-Wall -W -ansi -O3
LDLIBS=

# If compiling a C program (instead of C++), comment out this line:
LINK.o=$(LINK.cpp)


# --- No need to modify anything below this line ---
$(BINARY): $(SOURCES:.cc=.o)

..dep:
g++ -MM $(SOURCES) > .dep

-include .dep
#----------------------------------------------------------------

Lionel B 06-26-2008 10:45 AM

Re: isthere any tools that could help me check include dependencybetween c++ files?
 
On Thu, 26 Jun 2008 10:11:46 +0000, Juha Nieminen wrote:

> thinktwice wrote:
>> sometimes project compile error just because incorrect include relation
>> between files. and it's a headache to check manually, i want to know is
>> there any tools could help me to do that?

>
> You don't specify your platform nor the compiler you are using, which
> makes answering your question very difficult.
>
> I'll assume you are using gcc (or one of its ported variants) because
> that's about the only one where there are no project files per se (but
> instead makefiles are used).


Well, `make' might be used... it's not the only build utility around
(albeit the most widely used with gcc).

> gcc itself can be used to generate a Makefile-compatible file
> dependency listing, like this:
>
> gcc -MM <source files here>
>
> (You don't have to specify header files there.)


Correct me if I'm wrong, but I think the -MM flag isn't that clever: it
simply chugs out dependencies *as found in the source file*. To quote
from the docs: "The preprocessor outputs one make rule containing the
object file name for that source file, a colon, and the names of all the
included files ..."

I suspect this won't be that helpful to the OP (although I admit that I
don't really know, as I'm far from clear what the OP actually wants/
expects).

[...]

--
Lionel B

Juha Nieminen 06-26-2008 02:34 PM

Re: isthere any tools that could help me check include dependencybetween c++ files?
 
Lionel B wrote:
> Correct me if I'm wrong, but I think the -MM flag isn't that clever: it
> simply chugs out dependencies *as found in the source file*.


How else can a source file depend on another?

James Kanze 06-27-2008 09:04 AM

Re: isthere any tools that could help me check include dependencybetween c++ files?
 
On Jun 26, 4:34 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> Lionel B wrote:
> > Correct me if I'm wrong, but I think the -MM flag isn't that
> > clever: it simply chugs out dependencies *as found in the
> > source file*.


> How else can a source file depend on another?


If I understood him correctly, he's worried about logical
dependencies. His problem isn't to find out who includes what,
but who should include what.

(For the rest, most Unix compilers I know have some mechanism
for automatically generating the dependencies, and every
compiler I've ever seen has a possibility of generating
preprocessor output with #line directives... after which, a
simple shell script can be used to get a list of included
files.)

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique oriente objet/
Beratung in objektorientierter Datenverarbeitung
9 place Smard, 78210 St.-Cyr-l'cole, France, +33 (0)1 30 23 00 34

Lionel B 06-30-2008 09:33 AM

Re: isthere any tools that could help me check include dependencybetween c++ files?
 
On Fri, 27 Jun 2008 02:04:13 -0700, James Kanze wrote:

> On Jun 26, 4:34 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
>> Lionel B wrote:
>> > Correct me if I'm wrong, but I think the -MM flag isn't that clever:
>> > it simply chugs out dependencies *as found in the source file*.

>
>> How else can a source file depend on another?

>
> If I understood him correctly, he's worried about logical dependencies.
> His problem isn't to find out who includes what, but who should include
> what.


Yes, that is kind of how I understood the OP's issue.

I'm periodically vexed by something similar: both myself and, it seems,
compiler writers, are a bit vague as to which standard library headers
the C++ standard requires to be included for some particular
functionality. Since standard library headers will frequently #include
other standard library headers there is in practice much leeway as to
which headers you include in your code to get a compilable program. Then
you upgrade your compiler or use a different compiler and your code no
longer compiles because the "internal" standard library includes have
changed.

--
Lionel B


All times are GMT. The time now is 08:22 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.