Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #28281
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: How to transmit the value of an enumeration |
| Date | 2018-10-24 17:05 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <pqq1nl$4ja$1@dont-email.me> (permalink) |
| References | <pqpkdn$ed3$1@dont-email.me> <2f1efaa1-e0f4-47ba-a052-3b86f43c8d56@googlegroups.com> <pqprem$pnv$1@dont-email.me> |
On 24/10/18 15:18, pozz wrote:
> Il 24/10/2018 13:45, Jack ha scritto:
>> On Wednesday, October 24, 2018 at 1:18:20 PM UTC+2, pozz wrote:
>>> enum type_t {
>>> TYPE_1,
>>> TYPE_2,
>>> ...
>>> TYPE_100,
>>> }
>>>
> [...]
>>>
>>> What is your strategy?
>>
>> Long answer: read the definition of "enumeration"
>>
>> Short answer:
>> An enumeration is a normal type disguised and is implementation
>> dependent. Usually is signed int (whatever it means) but you have to
>> check your compiler doc to be sure.
>
> These details are generally important, but not for my question. I don't
> know if C standard guarantees that, if not specified, the first value is
> zero and the others are contiguous. If it is guaranteed, my example
> above works. Otherwise, the declaration of my enumeration should have
> been:
>
Enumeration constants in C are always of type "int", unless your
compiler has non-conforming modes that it documents and that you
actively use. (In C++, you can specify the underlying type and the
enumeration itself is a type.)
The first enumerator has value 0 if it is not given explicitly. Each
other enumerator is one more than the previous enumerator, if there is
no explicit value given.
When giving enumerators explicitly, it is fine to have duplicates and
overlaps.
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to transmit the value of an enumeration pozz <pozzugno@gmail.com> - 2018-10-24 13:18 +0200
Re: How to transmit the value of an enumeration Jack <jack4747@gmail.com> - 2018-10-24 04:45 -0700
Re: How to transmit the value of an enumeration pozz <pozzugno@gmail.com> - 2018-10-24 15:18 +0200
Re: How to transmit the value of an enumeration David Brown <david.brown@hesbynett.no> - 2018-10-24 17:05 +0200
Re: How to transmit the value of an enumeration David Brown <david.brown@hesbynett.no> - 2018-10-24 15:10 +0200
Re: How to transmit the value of an enumeration pozz <pozzugno@gmail.com> - 2018-10-24 15:27 +0200
Re: How to transmit the value of an enumeration David Brown <david.brown@hesbynett.no> - 2018-10-24 16:59 +0200
Re: How to transmit the value of an enumeration Clifford Heath <no.spam@please.net> - 2018-10-25 08:57 +1100
Re: How to transmit the value of an enumeration Joe Chisolm <jchisolm6@earthlink.net> - 2018-10-24 12:48 -0500
Re: How to transmit the value of an enumeration pozz <pozzugno@gmail.com> - 2018-10-24 23:20 +0200
Re: How to transmit the value of an enumeration Joe Chisolm <jchisolm6@earthlink.net> - 2018-10-24 22:21 -0500
Re: How to transmit the value of an enumeration David Brown <david.brown@hesbynett.no> - 2018-10-25 09:31 +0200
Re: How to transmit the value of an enumeration Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2018-10-25 09:58 -0700
Re: How to transmit the value of an enumeration Joe Chisolm <jchisolm6@earthlink.net> - 2018-10-25 18:38 -0500
Re: How to transmit the value of an enumeration David Brown <david.brown@hesbynett.no> - 2018-10-26 09:24 +0200
Re: How to transmit the value of an enumeration George Neuner <gneuner2@comcast.net> - 2018-10-24 15:19 -0400
Re: How to transmit the value of an enumeration Les Cargill <lcargill99@comcast.com> - 2018-10-26 20:30 -0500
csiph-web