From: Eric Rudd 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: Reply-To: rudd AT cyberoptics DOT com NNTP-Posting-Host: rudd.cyberoptics.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Eli Zaretskii wrote: > > On Wed, 20 May 1998, Eric Rudd wrote: > > > #include > > #include > > 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