Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mcvax!ukc!its63b!aiva!richard From: richard@aiva.ed.ac.uk (Richard Tobin, JANET: R.Tobin@uk.ac.ed ) Newsgroups: comp.lang.c Subject: Re: Distinguished pointers (was Re: Weird syscall returns) Message-ID: <123@aiva.ed.ac.uk> Date: Mon, 3-Aug-87 11:56:14 EDT Article-I.D.: aiva.123 Posted: Mon Aug 3 11:56:14 1987 Date-Received: Sat, 8-Aug-87 08:58:58 EDT References: <1158@copper.TEK.COM> <8317@utzoo.UUCP> Reply-To: richard@uk.ac.ed.aiva (Richard Tobin) Distribution: comp Organization: AI Applications Institute, Edinburgh University Lines: 33 In article <8317@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes: >Put the following code fragment into a file and include it in your library: > > char myio_no; > char myio_null; > >And then include this in the include file for your library: > > #define NOFILE ((FILE *)&myio_no) > #define NULLFILE ((FILE *)&myio_null) Is this valid in all Ansi-conforming implementations? That is, is a comparison like if(file == NOFILE) valid? My copy of the draft C standard says (apropos of pointer comparisons): "If the objects pointed to are not members of the same aggregate object, the result is undefined" and that seems to apply here. I assume this restriction is to allow segmented architectures to just compare the segment offset (or is there another reason?). Of course, if the routines can be arranged to always return pointers from the same array, then the out-of-band values could be in the same array, and all would be well. My copy of the C standard is a little (18 months) out of date, so maybe this has changed. -- Richard Tobin, JANET: R.Tobin@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@cs.ucl.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin