Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <200007060317.UAA17917@aleph.ssd.hal.com> Subject: Re: include incompatibilities To: cygwin AT sourceware DOT cygnus DOT com (Cygwin Mailing List) Date: Wed, 5 Jul 2000 20:17:31 -0700 (PDT) In-Reply-To: <200007031336.PAA23582@mail.bln1.siemens.de> from "towo@computer.org" at Jul 03, 2000 03:36:35 PM From: "J. J. Farrell" X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > From: towo AT computer DOT org > > I had apparently been mislead by the Linux manpage: > > NAME > > perror - print a system error message > > SYNOPSIS > > ... > > const char *sys_errlist[]; > > int sys_nerr; > > CONFORMING TO > > ANSI C, BSD 4.3, POSIX, X/OPEN > So apparently this manpage is wrong with respect to the "conforming" > attributes of these two definitions. Looks like it's a buggy man page. The conformance statements are presumably right for perror(), but they're wrong for the others. > Also, there are some reasons I did not use strerror(). > One is, strerror may depend on setlocale but setlocale is not available > on older systems. I don't understand what you mean by this. If a hosted environment conforms to C89 then it has strerror(). There is no dependency on other routines. > Another is incompatibilities with respect to undefined > values: > Linux: > > SYNOPSIS > > char *strerror(int errnum); > > RETURN VALUE > > The strerror() function returns ... an unknown error message > > if the error code is unknown. > > Sun: > > SYNOPSIS > > char *strerror(int errnum); > > ERRORS > > strerror returns NULL if errnum is out-of-range. > > So there is no real standard here either... The C Standard is that there are no errors. You're only supposed to pass strerror() values you got from errno, and these are assumed to always be valid. X/OPEN extended this by defining strerror() as setting errno to EINVAL if errnum is not valid. You should set errno to 0 before calling strerror() then check errno for EINVAL before using the result. Anything which conforms to X/OPEN XPG3 or later works in this way, and that includes most versions of UNIX released since 1989 and everything which conforms to UNIX95 or UNIX98. -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com