Apology for not C++ topic but its nearby

Apology for not C++ topic but instead its nearby 'meta' process

Why g++ option -MM -MF afile is not the same as -MM > afile ?
The first is defected i.e. incorrect and incomplete, how come while its reference means the same

-MM Like ‘-M’ but do not mention header fi les that are found in system header directories, nor header fi les that are included, directly or indirectly, from such a header. This implies that the choice of angle brackets or double quotes in an ‘#include’ directive does not in itself determine whether that header appears in ‘-MM’ dependency output.
-MF file When used with ‘-M’ or ‘-MM’, specifies a file to write the dependencies to. If no ‘-MF’ switch is given the preprocessor sends the rules to the same place it would send preprocessed output. When used with the driver options ‘-MD’ or ‘-MMD’, ‘-MF’ overrides the default dependency output file.
Last edited on
Huh?

1
2
3
4
5
#include <stdio.h>
#include "stdlib.h"  // a system header using "", not <>
#include "getch.h"
int main ( ) {
}


They all look the same to me.

To stdout.

$ gcc -M bar.c
bar.o: bar.c /usr/include/stdc-predef.h /usr/include/stdio.h \
 /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
...
 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h getch.h
$ gcc -MM bar.c
bar.o: bar.c getch.h


To file.

$ gcc -M -MF tmp bar.c
$ cat tmp 
bar.o: bar.c /usr/include/stdc-predef.h /usr/include/stdio.h \
 /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
...
 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h getch.h
$ gcc -MM -MF tmp bar.c
$ cat tmp 
bar.o: bar.c getch.h


To redirect.

$ gcc -M bar.c > tmp
$ cat tmp 
bar.o: bar.c /usr/include/stdc-predef.h /usr/include/stdio.h \
 /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
 /usr/include/x86_64-linux-gnu/bits/wordsize.h \
...
 /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
 /usr/include/x86_64-linux-gnu/bits/stdlib-float.h getch.h
$ gcc -MM bar.c > tmp
$ cat tmp 
bar.o: bar.c getch.h
Not such, but as it's inside makefile , strongly suspected only if it has VPATH identifier name
Topic archived. No new replies allowed.