Re: declaring errno
From: Dave Thompson (david.thompson1_at_worldnet.att.net)
Date: 04/26/04
- Next message: Dave Thompson: "Re: Large arrays: malloc or 'just declare'?"
- Previous message: Dave Thompson: "Re: trouble reading from file"
- In reply to: Mac: "declaring errno"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 26 Apr 2004 03:07:23 GMT
On Wed, 21 Apr 2004 21:06:06 -0700, "Mac" <foo@bar.net> wrote:
> Is it legal to declare errno after you've included errno.h?
<snip>
> I see in the standard that errno may be a macro, and I see that defining
> errno is illegal, but I don't think the declaration above counts as a
> definition since it doesn't reserve storage. On the other hand, if errno
> IS a macro, the declaration above could easily be a syntax error after
> pre-processing.
>
7.1.3p1 list items 3 and 5:
Each macro name in any of the following subclauses (including the
future library
directions) is reserved for use as specified if any of its associated
headers is included;
unless explicitly stated otherwise (see 7.1.4).
Each identifier with file scope listed in any of the following
subclauses (including the
future library directions) is reserved for use as a macro name and as
an identifier with
file scope in the same name space if any of its associated headers is
included.
errno is either a macro or an identifier with external linkage, per
7.5p2.
7.1.3p2 <snip> If the program declares or defines an identifier in a
context in which it is reserved (other than as allowed by 7.1.4), or
defines a reserved
identifier as a macro name, the behavior is undefined.
and none of the exceptions in 7.1.4 covers errno, so declaring it,
even without defining, is UB; for exactly the reasons others have
answered and you have discovered.
- David.Thompson1 at worldnet.att.net
- Next message: Dave Thompson: "Re: Large arrays: malloc or 'just declare'?"
- Previous message: Dave Thompson: "Re: trouble reading from file"
- In reply to: Mac: "declaring errno"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|