Thread: makefile dependencies (again)

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    552

    makefile dependencies (again)

    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.

  2. #2
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    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.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    6
    > 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]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with makefile
    By New_Programmer in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2009, 04:55 PM
  2. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 11:50 PM
  3. Makefile dependencies
    By taurus in forum C Programming
    Replies: 1
    Last Post: 11-09-2008, 12:17 AM
  4. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM
  5. makefile dependencies
    By *ClownPimp* in forum C++ Programming
    Replies: 7
    Last Post: 05-01-2002, 11:33 AM