Reputation: 815
For instance, in
#include <stdio.h>
what's the easiest way to figure out the path to the included file?
Edit: I'm using gcc 9.2.0 on Arch Linux.
Upvotes: 0
Views: 389
Reputation: 67476
You need to find where gcc is searching for the include files.
Try
echo | gcc -E -Wp,-v -
on my computer (Ubuntu on windows 10) it shows
piotr@DESKTOP-6R1GELF:~$ echo | gcc -E -Wp,-v -
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/7/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"
Upvotes: 2
Reputation: 659
I do usually generate dependencies in my Makefile
with the following command line:
gcc main.c -o main -MD
The -MD
flag generates a dependency file, where all included headers are listed.
Upvotes: 3