Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > isthere any tools that could help me check include dependency between c++ files$B!)(B

Reply
Thread Tools

isthere any tools that could help me check include dependency between c++ files$B!)(B

 
 
thinktwice
Guest
Posts: n/a
 
      06-24-2008
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?
 
Reply With Quote
 
 
 
 
thinktwice
Guest
Posts: n/a
 
      06-24-2008
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 6月24日, 下午9时01分, 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


 
Reply With Quote
 
 
 
 
Puppet_Sock
Guest
Posts: n/a
 
      06-24-2008
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
 
Reply With Quote
 
AnonMail2005@gmail.com
Guest
Posts: n/a
 
      06-24-2008
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
 
Reply With Quote
 
ManicQin
Guest
Posts: n/a
 
      06-25-2008
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 6月24日, 下午9时01分, 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?
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      06-26-2008
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
#----------------------------------------------------------------
 
Reply With Quote
 
Lionel B
Guest
Posts: n/a
 
      06-26-2008
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
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      06-26-2008
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?
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      06-27-2008
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:
Conseils en informatique orient閑 objet/
Beratung in objektorientierter Datenverarbeitung
9 place S閙ard, 78210 St.-Cyr-l'蒫ole, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
Lionel B
Guest
Posts: n/a
 
      06-30-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
how to understand Ruby code? (noting various mixins/includes) Isthere a tool to assist here? Greg Hauptmann Ruby 4 12-08-2009 06:21 PM
rails console output shows "\n" rather than putting in new line? isthere a way to change this? Greg Hauptmann Ruby 5 01-20-2009 10:47 PM
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57