www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/21/11:02:54

From: Eric Rudd <rudd AT cyberoptics DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Code to Fix sinh() in libm.a
Date: Thu, 21 May 1998 08:51:47 -0500
Organization: CyberOptics
Lines: 34
Message-ID: <35643173.2EA33CE3@cyberoptics.com>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980521104951 DOT 29054K-100000 AT is>
Reply-To: rudd AT cyberoptics DOT com
NNTP-Posting-Host: rudd.cyberoptics.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Eli Zaretskii wrote:
> 
> On Wed, 20 May 1998, Eric Rudd wrote:
> 
> > #include <errno.h>
> > #include <stdio.h>
> > int main(void) {
> >    printf("errno = %d", errno);
> >    return 0;
> > }
> >
> > When I'm shelled out from Win95, it prints errno = 0, as one would
> > expect. However, in MS-DOS mode, with himem.sys but no emm386, it prints
> > out errno = 27. In order to test the errno handling, I have needed to
> > initialize errno myself. Any ideas about what's wrong here?
> 
> A program that wants to see whether a certain function call sets
> errno, should set errno to zero before the call and test its value
> after the call.  Otherwise, what you see is the last value assigned to
> errno, which could be anywhere in the program.  In the above test
> program, I'd guess the value comes from the startup code which behaves
> differently on DOS and Windows (27 is ENOSYS, so I think this errno
> comes from the call to _use_lfn which tests whether long file names
> are supported).

That was indeed the case. I tried setting LFN=n, shelling out from
Win95, and the program then printed out 27 instead of zero. Nonetheless,
I consider this an error, since in 7.1.4 of the ANSI standard, it says

   "The value of errno is zero at program startup, but is never set to
   zero by any library function."

-Eric Rudd
rudd AT cyberoptics DOT com

- Raw text -


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