libc/include/sys/errno.h

Kazuhiro Fujieda fujieda@jaist.ac.jp
Wed Apr 23 16:20:00 GMT 2003


>>> On Wed, 23 Apr 2003 12:02:20 -0400
>>> "J. Johnston" <jjohnstn@redhat.com> said:

> Unfortunately, the variable is not historically declared
> const.  If you look at glibc, djgpp, and BSD, you will see
> that is declared as newlib does.  Therefore, the declaration
> should be left as-is.

The reason isn't only historical, but also compliant to the
standard. If it is declared const, the following code described
as the typical way of using errno in "C A Reference Manual"
can't work anymore.

    errno = 0;
    x = sqrt(y);
    if (errno) {
        printf("?sqrt failed, code %d\n", errno);
	x = 0;
    }
____
  | AIST      Kazuhiro Fujieda <fujieda@jaist.ac.jp>
  | HOKURIKU  Center for Information Science
o_/ 1990      Japan Advanced Institute of Science and Technology



More information about the Cygwin-developers mailing list