Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!pt!dld From: dld@F.GP.CS.CMU.EDU (David Detlefs) Newsgroups: gnu.gcc Subject: Re: Is "#pragma once" necessary? Message-ID: Date: 26 Jul 89 16:41:08 GMT References: Organization: CMU CS Department Lines: 41 In-reply-to: grunwald@flute.cs.uiuc.edu's message of 25 Jul 89 17:51:01 GMT In response to my suggestion about modify cpp to get the efficiency of "#pragma once" without the change in semantics, Dirk Grunwald writes: >hacking cpp to recognize #ifndef sounds like even more of a problem; >people have different conventions on where they place the #ifndef, >the #define and so on. I don't see the problem. cpp can certainly distinguish between comments and actual program text. If you write a foo.h file of the form -------------------------------------------------- * #ifndef FOO_H #endif * -------------------------------------------------- then cpp is certainly safe in disregarding subsequent includes of foo.h that occur while FOO_H is defined. If you have anything other than a comment or whitespace before the #ifndef, or after the corresponding #endif, then cpp might not be safe in ignoring subsequent includes. There is certainly no difficulty in recognizing file of this form, and I believe that pretty much all files using the #ifndef convention fit it. As for #requires and #provides, I think we have to recognize that we're going to exist for a long time in a sea of previously existing code, and we shouldn't change a perfectly good mechanism without good reason. I fail to see adequate advantages with #requires and #provides (though this does not of course imply thay such advantages do not exist.) -- 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.)