[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Current CVS: incorrect re-decrlaration of errno
From: |
Ralph Corderoy |
Subject: |
Re: Current CVS: incorrect re-decrlaration of errno |
Date: |
22 Sep 2000 22:48:56 +0100 |
Hi Werner,
> > #include <errno.h>
> > ...
> > #ifndef errno
> > extern int errno;
> > #endif
> >
> > This is plain wrong; you cannot assume that errno is #define'd. It
> > is *declared* in <errno.h> and the second redeclaration fails for
> > C++ (well, it may be subtle namespace problem - our compiler does
> > some tricks with namespaces in standard includes).
>
> At least for C you are wrong. According to the ISO C standard, errno
> may be a macro (and glibc indeed uses a macro). I'll have a look
> into the C++ standard, but I doubt this has changed since it would
> break backwards compatibility.
The original author says we cannot assume that errno is a macro and you
say he's wrong but then point out ISO says it *may* be a macro. I
think that means you really agree :-)
>From Harbison and Steele's _C, A Reference Manual_:
In ANSI C errno need not be a variable; it can be a macro that
expands to any modifiable lvalue, such as a dereferenced pointer
returned by a function:
extern int *_errno();
#define errno (*_errno())
Since it doesn't have to be a macro, and I think it is fairly common
that it isn't, then the `#ifndef errno' test does seem wrong. Couldn't
it just be assumed that if <errno.h> is present to #include then it'll
sort out the relevant definition of errno?
Ralph.