[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Current CVS: incorrect re-decrlaration of errno
From: |
Andrej Borsenkow |
Subject: |
RE: Current CVS: incorrect re-decrlaration of errno |
Date: |
Fri, 22 Sep 2000 17:18:33 +0400 |
> -----Original Message-----
> From: Werner LEMBERG [mailto:address@hidden
> Sent: Friday, September 22, 2000 12:15 PM
> To: address@hidden; address@hidden
> Cc: address@hidden
> Subject: Re: Current CVS: incorrect re-decrlaration of errno
>
>
> > #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.
>
> Antoine, can you please comment this?
>
Of course, it can be a macro. Or it may *not* be a macro. On our system it is
a macro if compiled with threads support an plain variable if compiled
without.
What I meant - the '#ifndef errno' is incorrect, because you cannot assume
that errno does not exist even if it is undefined. So, the correct check would
be something like
#ifdef NEED_DECLARATION_OF_ERRNO
extern int errno;
#endif
-andrej