Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ctrsol!srcsip!jhereg!mark From: mark@jhereg.Minnetech.MN.ORG (Mark H. Colburn) Newsgroups: gnu.gcc Subject: Re: #pragma once Message-ID: <305@jhereg.Minnetech.MN.ORG> Date: 8 Nov 89 13:46:26 GMT References: <8910300524.AA11104@sugar-bombs.ai.mit.edu> <1989Nov1.094352.24529@paris.ics.uci.edu> <522@loft386.UUCP> Reply-To: mark@jhereg.UUCP (Mark H. Colburn) Distribution: gnu Organization: Open Systems Architects, Inc., Mpls, MN Lines: 34 In article <522@loft386.UUCP> dpi@loft386.UUCP (Doug Ingraham) writes: >#ifdef __GNUC__ >#pragma once >#endif >#ifndef __STRING_H >#define __STRING_H > >< The required string.h information here > > >#endif /* __STRING_H */ Ok, I'll finally admit it, I am a little confused as to why there is such a construct as the #pragma once. If you want to avoid including the file twice, why not use the "standard" method of enclosing the entire thing in "#ifdefs" as shown above: #ifndef __MYHEADER_H #define __MYHEADER_H
#endif /* __MYHEADER_H */ This works on any machine with a preprocessor, is portable across any compiler, does not use a #pragma, and is in widespread use today. Also, from the discussion which has ensued here about #pragma once, I assume that it does not always work correctly. Can someone enlighten me here? -- Mark H. Colburn mark@Minnetech.MN.ORG Open Systems Architects, Inc.