Reputation: 8278
Suppose I have a C program separated into several smaller files and include each other as follows :
Now I have the following queries as to what extent I am correct. Please correct me wherever I am wrong:
1. Which files have to recompiled after I make changes to process1.c?
main.c ?
2. Which files have to recompiled after I make changes to process1.h?
main.c and process1.c?
3. Which files have to recompiled after I make changes to list.h?
input.c and process2.c?
Upvotes: 2
Views: 71
Reputation: 12263
Simply put:
A file has to be recompiled if any of the files it depends on has been changed.
Note that this is recursive, so if any of the object files has changed because they have been recompiled, the program file (which normally depends on all object files) has to be re-built (i.e. linked, not compiled), too.
You might try SCons as an easier and more powerful alternative to good ol' make.
Upvotes: 0
Reputation: 87446
This is really easy. If X gets changed, any .c file that includes X (or is X) needs to get recompiled. The answers are:
Upvotes: 3
Reputation: 2937
I think the best answer to your question is to write a Makefile
and then to check which files are compiled after changing one like your question.
Upvotes: 0