Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cwjcc!hal!nic.MR.NET!shamash!nis!ems!amdahl!nsc!rfg From: rfg@nsc.nsc.com (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: Re: Including header files minimally. Message-ID: <8080@nsc.nsc.com> Date: 27 Nov 88 08:17:56 GMT References: <3561@pt.cs.cmu.edu> <7860@nsc.nsc.com> <3614@pt.cs.cmu.edu> <10873@ulysses.homer.nj.att.com> <1073@actnyc.UUCP> <738@quintus.UUCP> <1988Nov25.180309.9323@utzoo.uucp> Reply-To: rfg@nsc.nsc.com.UUCP (Ron Guilmette) Organization: National Semiconductor, Sunnyvale Lines: 35 In article <1988Nov25.180309.9323@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: >In most cases, the fact >that #including a file n times is the same as including it once is a >property of the file being included, not the file doing the including. Absolutely right Henry. I realized this very fact just before I suggested using the sid-uid bit on header files which are not to be included more than once. In hindsight though, I now realize that even that was a silly suggestion. I now think that putting something like: #once or #pragma once into such header files would be more appropriate, more clear, and a more portable solution. >The probability of trouble and mistakes will be much lower if it's the >file being included that determines whether future inclusions have any >effect. Exactly right. >The Waterloo "#pragma idempotent" strikes me as the right method; >among other things, it means that your code is portable. Is this (semantically) the same thing as I am suggesting? I have never heard of this before! If it has the effect of forcing the file it is found within to only be included once then I guess that there is at least one clear (although not yet standard) precedent for an approach to this problem.