From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a9b0810d3106d9b8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: David Thompson Newsgroups: comp.lang.ada Subject: Re: Fun with C Date: Thu, 28 Apr 2011 01:13:27 -0400 Organization: Poor Message-ID: References: <4dab6906$0$6893$9b4e6d93@newsspool2.arcor-online.net> <57a1fa4b-4730-41a8-be8a-82061ef9dc22@x37g2000prb.googlegroups.com> <4daca6ba$0$6773$9b4e6d93@newsspool3.arcor-online.net> <33973ba6-c390-4af1-9116-6facb12e2878@u12g2000vbf.googlegroups.com> <4dad9c1b$0$6875$9b4e6d93@newsspool2.arcor-online.net> <0ee0dce3-9121-4af2-9c54-cd15264969ff@t19g2000prd.googlegroups.com> <4db07e47$0$6771$9b4e6d93@newsspool3.arcor-online.net> <4db085b6$0$26801$882e7ee2@usenet-news.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx01.eternal-september.org; posting-host="Gnu3Xq836+gTmlL7My5jNg"; logging-data="27917"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NtcFu12o09ZQ2gZcwzFXCjVq/4++mDrI=" X-Newsreader: Forte Agent 3.3/32.846 Cancel-Lock: sha1:CzX/RpbRSwonlkEEPO054x7fSAc= Xref: g2news2.google.com comp.lang.ada:20035 Date: 2011-04-28T01:13:27-04:00 List-Id: On Thu, 21 Apr 2011 15:27:40 -0400, Hyman Rosen wrote: > On 4/21/2011 2:58 PM, Georg Bauhaus wrote: > > Suppose you could do the following in C. I trust that > > C programmers would find this really cool: > > > > #include > > > > enum Color {Red, Green, Blue}; > > typedef uint8_t rgb_intensity; > > > > int main(void) > > { > > rgb_intensity things[enum Color]; // This Here > > return 0; > > } > > That doesn't work for C because a variable of an enum type > may hold any integer value up to the number of bits taken s/up to/up to at least/ > by the largest enumerator (with a variation for negatives > that isn't important here). The C enum concept is meant to > encompass literals used as bit masks as well as singular > values. However, for the many C enums that are just sequential integers -- the default -- you can do this: enum Color { Red,Green,Blue, Color_BOUND }; some_t array [Color_BOUND]; // Red..Blue are valid subscripts This helps *some* especially in maintenance.