delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/03/10/08:27:16

Date: Tue, 10 Mar 1998 15:26:35 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
cc: djgpp-workers AT delorie DOT com
Subject: Re: errno constants in <errno.h>
In-Reply-To: <m0yCISP-000S2kC@inti.gov.ar>
Message-ID: <Pine.SUN.3.91.980310150933.4739B-100000@is>
MIME-Version: 1.0

On Tue, 10 Mar 1998, Salvador Eduardo Tropea (SET) wrote:

> rest of code without changes if you don't check for some particular errno 
> value. The program will behave just fine and will report accurate errors 
> without changing a line.

If I understand you correctly, you want the source to use errno as usual, 
and then have some compile-time magic to change that to reference the DOS 
error codes instead.

I think that this could be arranged, but it seems a bit too complicated to
me.  I list some of the problems with this approach below (most of them
have been mentioned already in this thread). 

I think a cleaner way would be for the programs which want to be portable 
to define a function for error reporting, which looks at appropriate 
variables on each platform.  It is true that this requires some effort 
from the program author(s), but I think that in the end there is no 
better way of achieving this.

Here are some problems with simple renaming of errno (by something like a 
bunch of #define's):

  1) You need to redefine all the Efoobar mnemonics, but their mapping is 
ambiguous.  For example, EACCES could be mapped to dozens of different DOS 
codes.  If some code says "if (errno == EACCES) ...", it will not easily 
map to something that could use the additional info in the DOS codes.

  2) DOS error code is not a single value: you could call a DOS function
to get extended error info, which returns another 3 (I think) values. 
This defies simple 1:1 mapping. 

  3) We will need a DOS-specific version of sys_errlist[].  (This is not 
a problem, it's just a lot of work to make such a beast.)

Note that this is all IMHO, I don't oppose to inclusion of such a 
functionality, as people who don't like it could avoid using it.

> My idea is to enable programs (like RHIDE) to report a better message without 
> touching a line.

Maybe we need a new function, which under DOS will produce additional 
messages based on DOS codes, and under other systems be a no-op?  Then 
programs who want better error messages would just call that function, 
after doing whatever is appropriate for errno.

- Raw text -


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