Thread View: comp.lang.c++
2 messages
2 total messages
Started by dld@F.GP.CS.CMU.
Mon, 27 Feb 1989 16:59
Re: Recursive #includes
Author: dld@F.GP.CS.CMU.
Date: Mon, 27 Feb 1989 16:59
Date: Mon, 27 Feb 1989 16:59
44 lines
1775 bytes
1775 bytes
Recently, Paul Chisholm replied to Dominich Samperi's query on this subject, saying that this idea had been beaten to death recently. He went on to summarize the discussion, saying roughly that the two extreme solutions to "the include file problem" are 1) Write "foo.h" in the form #ifndef _FOO_H_ #define _FOO_H_ 1 <contents of foo.h> #endif // _FOO_H_ This requires no modifications to cpp. 2) Build a cpp so that it never includes a file twice -- this increases efficeincy significantly because, unlike the above, it doesn't even have to open the file to determine that it doesn't need to be included. Unfortunately, despite what many of us might think about such usage, some files are written to be included multiple times. Many people in the discussion tried to find compromise solutions; I was one of them. Unfortunately, my idea didn't work. I'm posting to plug what I thought was the best solution I read; I think all cpp's should be written this way (I forget who proposed this -- they should take a bow, I think): When cpp first processes a file, it determines all non-comment, non-whitespace text in the file is enclosed in an #ifndef block, as above. If so, the file name and the variable whose definedness determines inclusion are put in a table. On subsequent includes, the file is opened and processed only if the variable is not defined. This would seem to have all the performance advantages of proposal 2, while retaining all the compatibility advantages of proposal 1. Just a marvelous idea. -- Dave Detlefs Any correlation between my employer's opinion Carnegie-Mellon CS and my own is statistical rather than causal, dld@cs.cmu.edu except in those cases where I have helped to form my employer's opinion. (Null disclaimer.) --
Re: Recursive #includes
Author: prc@maxim.ERBE.S
Date: Tue, 28 Feb 1989 10:30
Date: Tue, 28 Feb 1989 10:30
18 lines
787 bytes
787 bytes
In article <DLD.89Feb27115937@F.GP.CS.CMU.EDU>, dld@F.GP.CS.CMU.EDU (David Detlefs) writes: > 2) Build a cpp so that it never includes a file twice -- this > increases efficeincy significantly because, unlike the above, it > doesn't even have to open the file to determine that it doesn't need > to be included. Unfortunately, despite what many of us might think > about such usage, some files are written to be included multiple > times. Well, then make it switch configureable with the "new" behavior as the default. -- Robert Claeson, ERBE DATA AB, P.O. Box 77, S-175 22 Jarfalla, Sweden Tel: +46 (0)758-202 50 Fax: +46 (0)758-197 20 EUnet: rclaeson@ERBE.SE uucp: {uunet,enea}!erbe.se!rclaeson ARPAnet: rclaeson%ERBE.SE@uunet.UU.NET BITNET: rclaeson@ERBE.SE
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads