Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: assigning constant values to complex structure Date: Mon, 17 Dec 2018 18:56:31 -0800 Organization: None to speak of Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader01.eternal-september.org; posting-host="293fcf4c88fbd1418164e5e9e2c7a0cd"; logging-data="16776"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188/xvuMROfInwyRNtju+w9" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:8/Ijdcur3DAYJMYDampfNgcQeXI= sha1:855u6la+dKGF2RICbf9GNUICEvs= Xref: csiph.com comp.lang.c:138727 Bart 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 Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"