Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.std.c > #6451 > unrolled thread
| Started by | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| First post | 2022-11-19 18:08 -0800 |
| Last post | 2022-11-20 13:58 -0800 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.std.c
Invalid sample definition for errno Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-11-19 18:08 -0800
Re: Invalid sample definition for errno Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-11-20 05:26 -0800
Re: Invalid sample definition for errno Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-11-20 13:58 -0800
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2022-11-19 18:08 -0800 |
| Subject | Invalid sample definition for errno |
| Message-ID | <87r0xyl6nm.fsf@nosuchdomain.example.com> |
A footnote in the section describing <errno.h> says:
The macro errno need not be the identifier of an object. It might
expand to a modifiable lvalue resulting from a function call (for
example, *errno()).
Footnotes are non-normative, and this one is presumably intended to be
informal, but that's not a valid macro definition for errno, both
because it's not fully protected by parentheses and because the function
can't be named "errno".
A valid definition (and the one used by glibc) is:
# define errno (*__errno_location ())
I suggest the footnote should be updated to use something like that
(though it needn't show the entire #define directive).
The same wording appears starting in C90 and up to and including the
latest C23 draft.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [next] | [standalone]
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Date | 2022-11-20 05:26 -0800 |
| Message-ID | <86sfidbvu7.fsf@linuxsc.com> |
| In reply to | #6451 |
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: > A footnote in the section describing <errno.h> says: > > The macro errno need not be the identifier of an object. It might > expand to a modifiable lvalue resulting from a function call (for > example, *errno()). > > Footnotes are non-normative, and this one is presumably intended to be > informal, but that's not a valid macro definition for errno, both > because it's not fully protected by parentheses and because the function > can't be named "errno". I see no reason the function couldn't be named "errno".
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2022-11-20 13:58 -0800 |
| Message-ID | <87edtxl24c.fsf@nosuchdomain.example.com> |
| In reply to | #6452 |
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> A footnote in the section describing <errno.h> says:
>>
>> The macro errno need not be the identifier of an object. It might
>> expand to a modifiable lvalue resulting from a function call (for
>> example, *errno()).
>>
>> Footnotes are non-normative, and this one is presumably intended to be
>> informal, but that's not a valid macro definition for errno, both
>> because it's not fully protected by parentheses and because the function
>> can't be named "errno".
>
> I see no reason the function couldn't be named "errno".
My thought was that giving the function and the macro the same name
would cause a conflict, and I thought I had an example that demonstrated
it. Looking again, I was mistaken:
If the name of the macro being replaced is found during this scan of
the replacement list (not including the rest of the source file’s
preprocessing tokens), it is not replaced.
I still suggest that using the same name for both is needlessly
confusing.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [standalone]
Back to top | Article view | comp.std.c
csiph-web