Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #150259
| Newsgroups | comp.lang.c |
|---|---|
| Date | 2020-02-25 21:17 -0800 |
| References | <aaf0f57f-4ae1-4c4a-a0aa-314eade48440@googlegroups.com> |
| Message-ID | <545cdc9b-e091-4584-9ccf-dbe915d60f03@googlegroups.com> (permalink) |
| Subject | Re: clarification about enums in C |
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
On Tuesday, February 25, 2020 at 6:38:47 PM UTC-5, Thiago Adams wrote:
> From the standard:
>
> "The identifiers in an enumerator list are declared as constants
> that have type int and may appear wherever such are permitted.127)"
That's from 6.7.2.2p3.
> But there is a foot note:
>
> "Each enumerated type shall be compatible with char, a signed
> integer type, or an unsigned integer type. The choice of type
> is implementation-defined,128)"
That is NOT a footnote. It's 6.7.2.2p4. The "127)" and "128)" that appear in those citations refer to actual footnotes.
> "128) An implementation may delay the choice of which integer
> type until all enumeration constants have been seen."
>
> I am confused.
>
> enum E { A, B};
>
> Can A and B be int and E not int?
> Can A B and E be != int?
A and B are enumeration constants, and are required, by the clause that you've cited, to have the type int. "Can" doesn't enter into the matter.
E is a tag for an enumerated type. "enum E" designates that type. The implementation must choose an integer type that enum E is compatible with, but enum E does not itself designate that type. The integer type that it's compatible with doesn't have to be "int", though it can be.
> If so, what is this
>
> "The identifiers in an enumerator list are declared as constants
> that have type int and may appear wherever such are permitted.127)"
That is the statement which specifies that A and B have the type int.
I suspect that those answers will still leave you confused. It might help if you were more specific about how they confuse you. In particular, what ideas do you have that are in conflict with those specifications?
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
clarification about enums in C Thiago Adams <thiago.adams@gmail.com> - 2020-02-25 15:38 -0800
Re: clarification about enums in C luser droog <luser.droog@gmail.com> - 2020-02-25 19:19 -0800
Re: clarification about enums in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-02-25 21:17 -0800
Re: clarification about enums in C Thiago Adams <thiago.adams@gmail.com> - 2020-02-27 04:01 -0800
Re: clarification about enums in C David Brown <david.brown@hesbynett.no> - 2020-02-26 11:29 +0100
Re: clarification about enums in C already5chosen@yahoo.com - 2020-02-26 14:05 -0800
Re: clarification about enums in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-26 23:03 +0000
Re: clarification about enums in C already5chosen@yahoo.com - 2020-02-26 23:29 -0800
Re: clarification about enums in C already5chosen@yahoo.com - 2020-02-27 01:42 -0800
Re: clarification about enums in C David Brown <david.brown@hesbynett.no> - 2020-02-27 11:02 +0100
Re: clarification about enums in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-27 06:37 -0800
Re: clarification about enums in C David Brown <david.brown@hesbynett.no> - 2020-02-27 16:18 +0100
Re: clarification about enums in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-02-27 23:24 -0500
Re: clarification about enums in C David Brown <david.brown@hesbynett.no> - 2020-02-27 09:50 +0100
Re: clarification about enums in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-27 06:33 -0800
Re: clarification about enums in C already5chosen@yahoo.com - 2020-02-27 06:53 -0800
Re: clarification about enums in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-27 15:05 +0000
Re: clarification about enums in C David Brown <david.brown@hesbynett.no> - 2020-02-27 16:24 +0100
Re: clarification about enums in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-28 01:27 -0800
Re: clarification about enums in C already5chosen@yahoo.com - 2020-02-27 01:29 -0800
Re: clarification about enums in C David Brown <david.brown@hesbynett.no> - 2020-02-27 11:12 +0100
Re: clarification about enums in C already5chosen@yahoo.com - 2020-02-27 03:09 -0800
Re: clarification about enums in C David Brown <david.brown@hesbynett.no> - 2020-02-27 14:33 +0100
Re: clarification about enums in C already5chosen@yahoo.com - 2020-02-27 05:44 -0800
Re: clarification about enums in C David Brown <david.brown@hesbynett.no> - 2020-02-27 14:57 +0100
Re: clarification about enums in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-27 11:53 +0000
Re: clarification about enums in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-02-27 23:52 -0500
Re: clarification about enums in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-28 01:30 -0800
Re: clarification about enums in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-26 14:09 +0000
Re: clarification about enums in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-26 09:47 -0800
Re: clarification about enums in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-26 21:04 +0000
csiph-web