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! 3 2029
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.
>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!
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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mechain Marc |
last post by:
In one of my logfiles I have quite repeatedly the following message:
InnoDB: Warning: using a partial-field key prefix in search
What does this warning mean ?
Regards,
Marc Mechain
Atos...
|
by: chand |
last post by:
Hi.,
In my api.py file 'g_opt_list' is defined globally
g_opt_list =,,,,,,]
I am using this global list in the fucntion
def function ():
gloabl g_opt_list
|
by: Walter Dnes (delete the 'z' to get my real address |
last post by:
I'm trying to initialize an array of error messages, so that I can
print out an error message by using the 'nth string in an array, e.g.
printf("%s\n", messages);
I'm still hazy on arrays of...
|
by: bingfeng |
last post by:
I have some codes generated by perl, in which initialize some huge
struct,such as
PARA TOS_network_spantree_set_0_para_0 = { "vlan", emNUM, NULL, "",
"configuration on a designated vlan",...
|
by: nick |
last post by:
the following is my programming code and compile message
why the warning message arise, have i done somethings wrong?
#include<stdio.h>
typedef struct card{
int abc;
}card;
|
by: Frederick Gotham |
last post by:
If we look at a programming language such as C++: When an updated Standard
comes out, everyone adopts it and abandons the previous one.
It seems though that things aren't so clear-cut in the C...
|
by: Aditya |
last post by:
Hi
I am using a line of as
char recvedValues = {'\0'};
in my code. I get a warning as near initialization for
recvedValues.
I am using gcc 3.4
Can anybody please explain the meaning.
Thanks...
|
by: Sebastian Faust |
last post by:
Hi,
Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?
The following...
|
by: Kenny O'Clock |
last post by:
This came up in a job interview, what is the output of the program
below? I tried to compile and run it myself, but my compiler (lcc-win32)
aborts with this errors....
Warning test2.c: 3 ...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |