Effectively what you want to do is to have the preprocessor ignore errors opening include files. I think there is a compiler with such a feature, but GCC isn't it. (Or maybe I'm confusing it with the GCC feature to ignore missing include files when generating dependency files.)
However what you can do instead is to create a shadow directory of empty files matching all the names and sub-directories for the system headers. You can then use the -nostdinc (to ignore the system include directories) and -I option (to point at your new shadow directory).
The shadow directory can be created with something like:
mkdir $HOME/tmp/emptystdinc
cd $HOME/tmp/emptystdinc
find /usr/include -type d -print | sed 's|/usr/include|.|' | xargs mkdir -p
find /usr/include -type f -print | sed 's|/usr/include|.|' | xargs touch
Now see what your post-processed code looks like:
cc -E -nostdinc -I$HOME/tmp/emptystdinc test.c
Good luck! This works fine for me!
#includeto@include(for sake of argument), then usegcc -E, if necessary, remapping the@includeback to#include. I'm not sure there'd be many other ways to do it. You could be selective and only map#include <angel-brackets.h>leaving#include "double-quotes.h"alone, so that the macros in those are expanded (amongst other side effects).@includetrick, you have to map copies of the files that are themselves included via#include "header.h". Which is the sort of reason it hasn't been done as standard. I'm not sure which flag you might have been using in college -- it doesn't sound like a standard one, or you'd be able to find it by going to the GCC documentation, reading the relevant CPP manual (e.g. CPP 5.1.0 "Invocation").