The options "-MD", "-MP", "-MF", and "-MT" are used by the GCC C compiler to generate dependency information. tell me the MD option by examples
时间: 2023-07-06 16:10:38 浏览: 48
Sure, the "-MD" option is used to generate dependency files in a Makefile format. These files can be used to automatically rebuild targets when their dependencies change. Here are some examples of how the "-MD" option can be used:
1. To generate a dependency file named "file.d" for a source file named "file.c":
```
gcc -MD -o file.o file.c
```
This will generate both "file.o" and "file.d" files. The "file.d" file will contain the dependencies for "file.o".
2. To specify a different name for the dependency file:
```
gcc -MD -MF dependencies.d -o file.o file.c
```
This will generate "file.o" and "dependencies.d" files. The "dependencies.d" file will contain the dependencies for "file.o".
3. To generate dependency files for multiple source files at once:
```
gcc -MD -MF dependencies.d -c *.c
```
This will generate object files and dependency files for all source files in the current directory. The "dependencies.d" file will contain the dependencies for all object files generated by this command.