file include follower - "cpp" does nicely

Guy Harris guy at rlgvax.UUCP
Tue Jun 5 15:28:46 AEST 1984


> I did not see this article, but I think that its conclusion
> is wrong.  As a file include follower, "cpp" has the following
> two bugs:
> (1) It will be fooled by #line directives.

True.  This is not a problem with most C code, only with that generated
by a program like YACC.  The include file follower which was submitted
to the net doesn't do anything special about this, but it could be
modified to do so (i.e., if it's chomping on a file "foo.y", it should
throw out all references to "foo.c").

> (2) It will look at #if, sometimes skipping some #include's which should
>     not be skipped.

That's not a bug, that's a feature.  Take the following:

	/*
	 * nnse - Nifty, neato screen editor.
	 * Author: Z. Beeblebrox.
	 */

	/*
	 * Grab the definitions of the TTY modes for the version of UNIX
	 * we're using.
	 */
	#ifdef USG
	#include <termio.h>
	#else
	#include <sgtty.h>
	#endif
	.
	.
	.

If you're generating a Makefile for a USG system, you may not want to
have "sgtty.h" listed as something the program depends on (although
it does happen to exist on USG systems), because it won't actually
pull it in.  The same applies to V7 and BSD systems (more so, since
"termio.h" doesn't exist there).  As such, you want to have the
#ifs processed - the Makefile will therefore be dependent on which
system you're compiling it for.  That's common, anyway; the program
might drag in different libraries on different versions of UNIX, for
example.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.sources.unix mailing list