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


Groups > comp.lang.c > #138727

Re: assigning constant values to complex structure

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: assigning constant values to complex structure
Date 2018-12-17 18:56 -0800
Organization None to speak of
Message-ID <lnk1k7ee5c.fsf@kst-u.example.com> (permalink)
References <pv9jcr$qg0$1@gioia.aioe.org> <TBYRD.63639$krL1.1252@fx15.am4>

Show all headers | View raw


Bart <bc@freeuk.com> writes:
[...]

> struct letteroclass_bin
> {
>      union
>      {
>          wint_t l;       // letter;
>          struct
>          {
>              unsigned char list1[20];
>              unsigned char list2[22];
>              unsigned char list3[29];
>          } jlist;
>      } letteroclass;
>      unsigned char current_data_type;
> } a = { L'a', 1 } ;
>
> But the elements must be constants.

In C99 or later, the elements need not be constant expressions unless
the object is static (defined with the "static" keyword or at file
scope).

-- 
Keith Thompson (The_Other_Keith) kst@mib.org  <http://www.ghoti.net/~kst>
Will write code for food.
"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 | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

assigning constant values to complex structure chano <chano@nospam.no> - 2018-12-18 01:43 +0000
  Re: assigning constant values to complex structure Bart <bc@freeuk.com> - 2018-12-18 02:05 +0000
    Re: assigning constant values to complex structure Keith Thompson <kst-u@mib.org> - 2018-12-17 18:56 -0800
  Re: assigning constant values to complex structure Keith Thompson <kst-u@mib.org> - 2018-12-17 18:31 -0800
    Re: assigning constant values to complex structure chano <chano@nospam.no> - 2018-12-18 18:11 +0000
      Re: assigning constant values to complex structure James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-18 10:58 -0800
      Re: assigning constant values to complex structure Keith Thompson <kst-u@mib.org> - 2018-12-18 12:05 -0800
    Re: assigning constant values to complex structure chano <chano@nospam.no> - 2018-12-19 19:44 +0000
      Re: assigning constant values to complex structure James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-19 11:50 -0800
        Re: assigning constant values to complex structure chano <chano@nospam.no> - 2018-12-19 20:27 +0000
          Re: assigning constant values to complex structure William Ahern <william@25thandClement.com> - 2018-12-19 13:20 -0800
          Re: assigning constant values to complex structure James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-19 14:08 -0800
          Re: assigning constant values to complex structure David Brown <david.brown@hesbynett.no> - 2018-12-20 08:15 +0100
  Re: assigning constant values to complex structure Siri Cruise <chine.bleu@yahoo.com> - 2018-12-19 14:59 -0800

csiph-web