Mail Archives: cygwin/2000/07/05/23:18:26
> 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
- Raw text -