Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ulysses!gsf From: gsf@ulysses.homer.nj.att.com (Glenn Fowler[drew]) Newsgroups: comp.lang.c++ Subject: Re: #once cpp directive implemented! Summary: #once -> #pragma once Message-ID: <11338@ulysses.homer.nj.att.com> Date: 20 Mar 89 14:17:43 GMT References: <124@riunite.ACA.MCC.COM> Organization: AT&T Bell Laboratories, Murray Hill Lines: 50 In article <124@riunite.ACA.MCC.COM>, rfg@riunite.ACA.MCC.COM (Ron Guilmette) writes: > As someone pointed out recently, the subject of multiple > inclusion of individual include files was beaten to death > here not long ago. > At the risk of starting it all up again, I would like to > announce the availability of patches for the the GNU C > preprocessor (version 1.34) which implement the new #once > directive. These patches may be aquired by simply sending > me mail and requesting the patches. I hope that these patches > will soon become a standard part of the GNU releases, but till > then, I will distribute them. implementing #once as #pragma once would be more in line with the current standards efforts since #pragma's may/must be ignored by certain implementations the paradigm would be #ifndef #define #pragma once ... #endif this would allow for: (1) portability -- works for all implementations that either ignore #pragma's or that implement once (2) efficiency for those implementations that implement once (3) compatibility with those implementations that implement the equivalent of once by detecting #ifndef...#endif wrapped include files (4) correctness for any errors/choices in the file identity algorithm (excuse the os-dependent examples): ln a.h b.h # "a.h" == "b.h" ? ln -s a.h b.h # "a.h" == "b.h" ? cd /tmp echo '' > stdio.h echo '#include "stdio.h"' > a.c echo '#include ' >> a.c # "stdio.h" == ? # "./a.h" == "a.h" ? # "$PWD/a.h" == "./a.h" ? (where $PWD really expanded) note that with NFS and RFS the same physical file accessed by different paths may have different -- Glenn Fowler (201)-582-2195 AT&T Bell Laboratories, Murray Hill, NJ uucp: {att,decvax,ucbvax}!ulysses!gsf internet: gsf@ulysses.att.com