what is the meaning of the Warning message,why it occurs?

Discussion in 'C Programming' started by nick, Oct 12, 2005.

  1. nick

    nick Guest

    i have 5 files,when i use make command to compile them a error occurs
    "make: Warning: Infinite loop: Target `c.o' depends on itself"

    when i type make an warning message occurs

    cc -c b.c
    cc -c a.c
    make: Warning: Infinite loop: Target `c.o' depends on itself
    cc -c c.c
    cc b.o a.o c.o -o a


    1. file :c.c
    #include <stdio.h>
    void print(){
    printf("%d",1);
    }

    2. file : c.h
    #ifndef t
    #define t
    #include <stdio.h>

    void print();
    #endif

    3. file : b.c
    #include "c.h"
    void print2(){
    printf("%d",2);
    }

    4. file : b.h
    void print2();

    5. file : a.c
    #include "b.h"
    #include "c.h"
    extern int h;
    int main(){
    print();
    print2();
    return 0;

    }

    the makefile
    a: b.o a.o c.o b.h c.h
    cc b.o a.o c.o -o a
    b.o: b.c b.h
    cc -c b.c
    c.o: c.o c.h
    cc -c c.c

    thanks!
     
    nick, Oct 12, 2005
    #1
    1. Advertising

  2. nick

    Skarmander Guest

    nick wrote:
    > i have 5 files,when i use make command to compile them a error occurs
    > "make: Warning: Infinite loop: Target `c.o' depends on itself"
    >

    <snip>

    This is not a C-specific question, you're having trouble writing makefiles.

    > c.o: c.o c.h


    You want c.c in the dependency list, not c.o.

    S.
     
    Skarmander, Oct 12, 2005
    #2
    1. Advertising

  3. >i have 5 files,when i use make command to compile them a error occurs
    >"make: Warning: Infinite loop: Target `c.o' depends on itself"


    Because c.o *DOES* depend on itself.

    >c.o: c.o c.h


    See that c.o on BOTH sides of the dependency? That's a mistake.

    Gordon L. Burditt

    >
    >when i type make an warning message occurs
    >
    >cc -c b.c
    >cc -c a.c
    >make: Warning: Infinite loop: Target `c.o' depends on itself
    >cc -c c.c
    >cc b.o a.o c.o -o a
    >
    >
    >1. file :c.c
    >#include <stdio.h>
    >void print(){
    >printf("%d",1);
    >}
    >
    >2. file : c.h
    >#ifndef t
    >#define t
    >#include <stdio.h>
    >
    >void print();
    >#endif
    >
    >3. file : b.c
    >#include "c.h"
    >void print2(){
    >printf("%d",2);
    >}
    >
    >4. file : b.h
    >void print2();
    >
    >5. file : a.c
    >#include "b.h"
    >#include "c.h"
    >extern int h;
    >int main(){
    >print();
    >print2();
    >return 0;
    >
    >}
    >
    >the makefile
    >a: b.o a.o c.o b.h c.h
    > cc b.o a.o c.o -o a
    >b.o: b.c b.h
    > cc -c b.c
    >c.o: c.o c.h
    > cc -c c.c
    >
    >thanks!
     
    Gordon Burditt, Oct 12, 2005
    #3
  4. nick

    Jaspreet Guest

    nick wrote:
    > i have 5 files,when i use make command to compile them a error occurs
    > "make: Warning: Infinite loop: Target `c.o' depends on itself"
    >
    > when i type make an warning message occurs
    >
    > cc -c b.c
    > cc -c a.c
    > make: Warning: Infinite loop: Target `c.o' depends on itself
    > cc -c c.c
    > cc b.o a.o c.o -o a
    >
    >

    [snip.c files]
    > the makefile
    > a: b.o a.o c.o b.h c.h
    > cc b.o a.o c.o -o a
    > b.o: b.c b.h
    > cc -c b.c
    > c.o: c.o c.h


    Why do you have c.o on both the sides ? Remove the one on the right and
    your warning should disappear. OT here though, nothing to do with c
    language.

    > cc -c c.c
    >
    > thanks!
     
    Jaspreet, Oct 12, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,137
    Smokey Grindel
    Dec 2, 2006
  2. bingfeng
    Replies:
    4
    Views:
    2,778
    bingfeng
    Jun 2, 2005
  3. Replies:
    4
    Views:
    802
  4. TS
    Replies:
    2
    Views:
    279
    Walter Wang [MSFT]
    Jun 20, 2006
  5. Geek
    Replies:
    3
    Views:
    151
Loading...

Share This Page