9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] initialization of anonymous structs.
Date: Thu,  4 Dec 2008 10:16:26 -0500	[thread overview]
Message-ID: <8e077f5ac8522f068a77a6d94d27794f@quanstro.net> (raw)
In-Reply-To: <df49a7370812040656o61714cc6x77961d50ad2c1d5d@mail.gmail.com>

> On Thu, Dec 4, 2008 at 12:33 PM, Sape Mullender
> <sape@plan9.bell-labs.com> wrote:
>> B bvar = {
>>        .B = {
>>                .a1 = 2,
>>                .b1 = 2,
>>        },
>> };
>
> that doesn't work for me.
> i get:
> x.c:18 structure element not found B
> x.c:18 more initializers than structure: bvar
>
> changing the .B to .A doesn't work either, nor does
> {.A = {.a1 = 3}, .b1 = 4}
> which intuitively (without looking at the compiler code) seems the
> most likely to work...

seems like a subtle compiler nit (i hope i'm not out-of-date
again), this initialization does work

B bvar = {
	{.a1 = 1,},
	.b1 = 1,
};

the {} fix the problem but should not be necessary.

- erik




      reply	other threads:[~2008-12-04 15:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-04 12:07 Gorka Guardiola
2008-12-04 12:26 ` Gorka Guardiola
2008-12-04 12:33   ` Sape Mullender
2008-12-04 14:56     ` roger peppe
2008-12-04 15:16       ` erik quanstrom [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e077f5ac8522f068a77a6d94d27794f@quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).