delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/03/11/06:39:43

Date: Wed, 11 Mar 1998 13:37:26 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
cc: Nate Eldredge <eldredge AT ap DOT net>,
djgpp workers list <djgpp-workers AT delorie DOT com>
Subject: Re: errno constants in <errno.h>
In-Reply-To: <Pine.LNX.3.93.980311113653.27664A-100000@acp3bf>
Message-ID: <Pine.SUN.3.91.980311133416.7959G-100000@is>
MIME-Version: 1.0

On Wed, 11 Mar 1998, Hans-Bernhard Broeker wrote:

> In other words: it's always an lvalue, but not necessarily a simple
> variable.
> 
> > The scheme I saw suggested was to do:
> > 
> > errno = 0; /* or EOK */
> > y = sqrt(x);
> > if (errno == EDOM) ...
> 
> This scheme happens to be explained in the following footnote in the
> Standard, yes. But then, there *have* to be better ways of handling such
> conditions.

Even though errno is an lvalue, it still makes sense to not assign
anything BUT ZERO to it.  For example, if we have

	#define errno (*get_errno_value())

then "errno = 0;" is OK, but "errno = EACCES;" is *not*.

I gather that is the reason for those "errno should be read-only" 
comments I've seen.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019