Reputation: 3328
According to GNU's documentation
If there are many included files then the rule is split into several lines using
\
-newline.
After running the following command, why is the output from gcc -M not as expected?
How do I ensure that each dependency appears on a separate line? Thanks for your help in advance.
gcc -Iinc/ -Isrc/ -M -MM src/BitSet.c
BitSet.o: src/BitSet.c \
inc/BitSet.h inc/StdDefs.h
I am using GCC 4.5.2 (MinGW) on Windows.
Upvotes: 1
Views: 1271
Reputation: 70333
You came to expect the wrong thing.
If there are many included files then the rule is split into several lines using \ -newline.
The rule is split if it is longer than a certain length. Nowhere does the documentation say that the rule will be split after each token.
I.e., fault in the expected output, not in the observed output.
Regarding your comment (building a build tool of your own that uses gcc -M
output for its dependency tracking)... the output of gcc -M
is meant to be parsed by make
, using make
's parsing rules. If you want to use the output yourself, you will have to follow the same parsing rules - which aren't that difficult to begin with.
Upvotes: 2