Questions on the result of dependency generation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I observed some weird results about the dependency generation.

Suppose the source code structure is as follows:

root
  |-- c
  |   |-- c.cpp
  |   |-- c.h

'c.cpp' includes the header file 'c.h' by
      #include "c/c.h"

Now I try to generate the dependencies for c/c.cpp.

(A) If I'm now in 'root' folder and run command
      g++ -MM -MT c/c.o c/c.cpp
the compiler outputs
      c/c.o : c/c.cpp    #  which is wrong because it lacks c/c.h

(B) If I'm in folder 'c' and run command
      g++ -MM -MT c.o c.cpp
the compiler can ouput the correct results
      c.o : c.cpp c.h

(C) If I'm in the parent folder of folder 'root' and run command
      g++ -I./root -MM -MT root/c/c.o root/c/c.cpp
the results is also correct:
      root/c/c,o : root/c/c.cpp root/c/c.h

(D) Now, if I'm in folder 'root' again and include the head file 'c.h'
for 'c.cpp' by
     #include "c.h"  instead of #include "c/c.h"
the result is also correct.

I'm wondering why (A) cannot give a correct dependency output but (B),
(C) and (D) can.

Thanks,



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux