gcc-stdinc queries gcc for its standard system include directories and prints them to standard output
Download Link: gcc-stdinc-1.0.tar.gz
$ gcc-stdinc c++ /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2 /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/i486-linux-gnu /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward /usr/local/include /usr/lib/gcc/i486-linux-gnu/4.1.2/include /usr/include $
Here is its usage information...
$ gcc-stdinc --help gcc-stdinc 1.0 -------------- This is free software. License is GPL2. gcc-stdinc prints to standard output the list of system include paths that are searched by the gcc preprocessor. USAGE: gcc-stdinc
...where lang is one of "c", "c++" etc. (see man gcc -x option) EXAMPLE: gcc-stdinc c++ -Andrew Tomazos <email@example.com>, Feb 2007
Here is a snippet of how to do it from within a .vimrc file to set your vim path option to gcc's standard system includes when vim launches.
You will need a vim compiled with the +perl option. The vim-full package on most linux distributions will have +perl enabled.
# ~/.vimrc perl << EOF my $std_inc_path = `echo | g++ -E -v -x c++ - 2>&1`; my $start_delim = '#include <...> search starts here:'; my $end_delim = 'End of search list.'; $std_inc_path =~ s/.*?\Q$start_delim\E(.*?)\Q$end_delim\E.*/$1/s; $std_inc_path =~ s/\s+/,/sg; $std_inc_path =~ s/(^\,)|(\,*$)//g; VIM::SetOption("path=.," . $std_inc_path . ",,"); EOF
Up to Andrew Tomazos Home Page