4 ms·
There are two independent problems here. Problem A: foo.c: #include "bar_auto.h" when you have a rule "%_auto.h: %_auto.xml". gcc -M on foo.c will not tell
by Peaker 12y ago
There are two independent problems here.
Problem A:
foo.c: #include "bar_auto.h"
when you have a rule "%_auto.h: %_auto.xml".
gcc -M on foo.c will not tell you about the dependence on "bar_auto.h", but will rather fail. With buildsome or a better #include scanner, you will know that foo.o depends on bar_auto.h, even though bar_auto.h does not yet exist.
Problem B:
x.c: #include "bla.h"
a/bla.h does not exist
b/bla.h does exist
gcc -Ia -Ib -o x.o -c x.c
gcc -M tells us that x.o depends on b/bla.h. We cache this information to avoid rerunning gcc -M every time. Then someone adds a/bla.h. A rebuild will change x.o, but "make" or whatever build system cached the result of "gcc -M" will not rebuild anything.
You might say "gcc -M" should be rerun each time, but this is extremely wasteful, as there's no reason to rescan all the .c/.h files every time, when they did not change.