Date: Tue, 10 Mar 1998 15:26:35 +0200 (IST) From: Eli Zaretskii To: "Salvador Eduardo Tropea (SET)" cc: djgpp-workers AT delorie DOT com Subject: Re: errno constants in In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.