There have been a number of times when I wanted to find out where an include file was in the default compiler search path and there have been other times when I wanted to find out which header file contained a specific setting so I created this simple little bash script that does both in the hopes that it will be useful.
#!/bin/bash
#
# This tool allows you to search for header files in the compiler
# search path using the find syntax.
#
# % find-header.sh -name unistd.h
# % find-header.sh -name syscall.h
#
# You can also search the contents of headers.
#
# % find-header.sh -name '*.h' -exec grep -n __NR_ {} \; -print
# % find-header.sh -iname '*.h' -exec grep -l __NR_ {} \;
#
# If you just want to see the include paths:
#
# % find-header.sh
#
# Collect the arguments.
N=$#
ARGS=()
while (( $# > 0 )) ; do
ARGS=( "${ARGS[@]}" "$1" )
shift
done
# Get the compiler paths for gcc and g++.
$(g++ -print-prog-name=cc1plus) -v > /tmp/$$.txt 2>&1 <> /tmp/$$.txt 2>&1 <