🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #415

Re: Error Return (was Re: (char *)(-1))

#415
From: Mike (I'll think of something ye...
Date: Sat, 05 Aug 1989 04:46
36 lines
1900 bytes
In article <594@cybaswan.UUCP> iiitsh@cybaswan.UUCP (Steve Hosgood) writes:
<I guess that an extension of the form:
<
<	if (errval(foo = bar())) {
<		<error code goes here>
<		<could use 'foo' to get more details of the error>
<	}
<
<..would be most acceptable. 'errval' could be made a reserved word on new
<systems (tests the carry bit), and implemented as a macro on older ones for
<backward compatability:
<
<# define	errval(x)	(x) < 0
<
<..or
<
<# define	errval(x)	(x) == -1
<
<..or something like that, though some sort of cast will be reqd of course.

How about:

#define errval(x)	(errno = 0, (x), errno)

It'll even work on the current standard. Whether you can get this to
turn into tweaks to the carry flag (I hope that nobody would advocate
referring to hardware flags in the standard; there's already hardware
that C runs on without such flags) in a standard-conforming compiler
is an interesting question.

	<mike
--
Can't buy happiness no matter what you do		Mike Meyer
Can't get to heaven on roller skates			mwm@berkeley.edu
Can't take a taxicab to Timbuktu			ucbvax!mwm
Life is hard.						mwm@ucbjade.BITNET
Technical Details
Message-ID: <26998@agate.BERKELEY.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!decwrl!ucbvax!agate!eris.berkeley.edu!mwm
References: <GEOFF.89Jun11231924@onyx.cs.warwick.ac.uk| <2619@yunexus.UUCP| <388@celit.UUCP| <118@psitech.UUCP| <1063@tukki.jyu.fi| <1282@cbnewsl.ATT.COM| <617@prles2.UUCP| <220@ssp1.idca.tds.philips.nl> <594@cybaswan.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!decwrl!ucbvax!agate!eris.berkeley.edu!mwm
From: mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer)
Newsgroups: comp.std.c
Subject: Re: Error Return (was Re: (char *)(-1))
Keywords: error, flag, exception
Message-ID: <26998@agate.BERKELEY.EDU>
Date: 5 Aug 89 04:46:49 GMT
References: <GEOFF.89Jun11231924@onyx.cs.warwick.ac.uk| <2619@yunexus.UUCP| <388@celit.UUCP| <118@psitech.UUCP| <1063@tukki.jyu.fi| <1282@cbnewsl.ATT.COM| <617@prles2.UUCP| <220@ssp1.idca.tds.philips.nl> <594@cybaswan.UUCP>
Sender: usenet@agate.BERKELEY.EDU
Reply-To: mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer)
Organization: Missionaria Phonibalonica
Lines: 36