PDA

View Full Version : makefile dependencies (again)



*ClownPimp*
05-02-2002, 02:24 PM
well, no one answered my question sufficiently enough on the C++ board to quench my thirst for knowledge, so I thought I'd ask it here (hope you dont mind)...

if main.cc includes input.h in its dependency list, and input.h includes io.h in its dependency list, should main.cc also include io.h in its dependency list (assuming io.h is just some random header file, not the io.h included with the compiler). Note that main.cc contains no references to anything defined in io.h, just input.h.

If so, then why. It seems to me that since main.cc doesn't contain any references to anything defined/declared in io.h, then it shouldn't include io.h in its dependency list.

[main.o] --> [input.o] --> [io.o]

the only time that main.c should be recompiled is if the "interface" of the functions and classes change in input.o (ie. input.h changes). But since main.o references nothing in io.h/io.o, there is no need for main.o to be recompiled if the io.h changes

If I'm wrong about this, i would like to know why.

Nick
05-02-2002, 09:03 PM
As long as main never call or define anything from io.h it is sufficient to just have input.c depend on io.h and input.h.
In any case if main.c does call stuft from io.h then you should
include io.h since the header guards should take care of duplicates.

M-21
05-06-2002, 03:13 AM
> If so, then why. It seems to me that since main.cc doesn't contain > any references to anything defined/declared in io.h, then it
> shouldn't include io.h in its dependency list.

> [main.o] --> [input.o] --> [io.o]

Each time 'make; want's to built [main.o], it's check the depencies of [input.o]. So, it's not necessary to put [io.o] in [main.o] depencies list, as long as you make depencies list for [input.o]