Search notes:

gcc -MM

Show dependencies of compilation units, excluding system header files. The printed output of dependencies is suitable to be copy-pasted into a Makefile.
In order to include system header files, use gcc -M.

Demonstration - Source files

The output of gcc -MM is demonstrated with the following three trivial compilation units and corresponding header files:
main.c:
#include "hello-world.h"

int main() {

  hello_world();

}
Github repository about-gcc, path: /options/MM/main.c
hello-world.c:
#include "hello-world.h"

void hello_world() {
  print_line("Hello world");
}
Github repository about-gcc, path: /options/MM/hello-world.c
hello-world.h:
#ifndef HELLO_WORLD
#define HELLO_WORLD

#include "print-line.h"

void hello_world();

#endif
Github repository about-gcc, path: /options/MM/hello-world.h
print-line.c:
#include "print-line.h"

void print_line(const char* line) {
  printf("%s\n", line);
}
Github repository about-gcc, path: /options/MM/print-line.c
print-line.h:
#ifndef PRINT_LINE_H
#define PRINT_LINE_H

#include <stdio.h>

void print_line(const char* line);

#endif
Github repository about-gcc, path: /options/MM/print-line.h

Demonstration - output

gcc -MM main.c prints
main.o: main.c hello-world.h print-line.h
gcc -MM hello-world.c prints
hello-world.o: hello-world.c hello-world.h print-line.h
gcc -MM print-line.c prints
print-line.o: print-line.c print-line.h

See also

GCC options

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740023486, '3.15.240.124', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/GCC/options/MM(111): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78