Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #127877

Re: enums in structs

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: enums in structs
Date 2018-03-15 10:19 -0700
Organization None to speak of
Message-ID <ln605x8de7.fsf@kst-u.example.com> (permalink)
References <a%iqC.2508$%a5.2417@fx21.am4> <lna7va88bg.fsf@kst-u.example.com> <1af57651-5ef0-4ffd-95bd-4e73a2fbc4eb@googlegroups.com>

Show all headers | View raw


supercat@casperkitty.com writes:
> On Wednesday, March 14, 2018 at 7:57:16 PM UTC-5, Keith Thompson wrote:
>> If "red", "green", and "blue" had scopes restricted to the struct
>> definition, you wouldn't be able to refer to their names outside the
>> struct definition.  C has no mechanism for prefixing an enumeration
>> constant with the name of a type.
>
> You can't refer to their names outside the context of an object of the
> appropriate structure type.

Look back at the example (which you snipped, of course).  "red",
"green", and "blue" are enumeration constants, not member names.

[SNIP]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

enums in structs bartc <bc@freeuk.com> - 2018-03-15 00:20 +0000
  Re: enums in structs Keith Thompson <kst-u@mib.org> - 2018-03-14 17:57 -0700
    Re: enums in structs supercat@casperkitty.com - 2018-03-14 20:04 -0700
      Re: enums in structs Keith Thompson <kst-u@mib.org> - 2018-03-15 10:19 -0700
    Re: enums in structs Steven Petruzzellis <frelwizzen@gmail.com> - 2018-03-14 20:07 -0700
    Re: enums in structs David Brown <david.brown@hesbynett.no> - 2018-03-15 11:36 +0100
  Re: enums in structs Thiago Adams <thiago.adams@gmail.com> - 2018-03-15 05:33 -0700
  Re: enums in structs "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-03-15 05:39 -0700
    Re: enums in structs Steven Petruzzellis <frelwizzen@gmail.com> - 2018-03-15 06:35 -0700
  Re: enums in structs jameskuyper@verizon.net - 2018-03-15 06:26 -0700

csiph-web