guy@rlgvax.UUCP (Guy Harris) (05/30/84)
A Makefile generator (the most common use of an include follower) was posted to "net.sources" by somebody a while ago. It used "cpp" to follow the include files - this has the advantage that it even understands "ifdef"s and the like. An example of this advantage, which crops up here a fair bit, is Makefiles for programs which provide a full-screen user interface. Such programs need an "#ifdef" for the V7/BSD tty driver vs. the USG tty driver; depending on the define, it will include <sgtty.h> or <termio.h>. That Makefile generator was one of the cleverer uses of "cpp" I've seen - all you do is "cc -E" the source and grab "# <linenum> <filename>" lines as they go by. Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy
dyer@vaxuum.DEC (Example #22) (06/01/84)
Re: file include follower - "cpp" does nicely__________________________________ Okay, anyone want to send me a copy? I missed it! <_Jym_>
kendall@wjh12.UUCP (Sam Kendall) (06/04/84)
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. (2) It will look at #if, sometimes skipping some #include's which should not be skipped. Sam Kendall {allegra,ihnp4,ima,amd70}!wjh12!kendall Delft Consulting Corp. decvax!genrad!wjh12!kendall
guy@rlgvax.UUCP (Guy Harris) (06/05/84)
> 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