linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Derek M Jones <derek@knosof.co.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Christopher Li <sparse@chrisli.org>
Cc: Josh Triplett <josh@joshtriplett.org>,
	Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: Designated initializers for fields in anonymous structs and unions
Date: Sat, 02 Aug 2014 19:31:20 +0100	[thread overview]
Message-ID: <53DD2E78.2050609@knosof.co.uk> (raw)
In-Reply-To: <CA+55aFzfdfh80o1-BUA4CqurZ_A94cbNwCxHJZi-aFdLc+hF+w@mail.gmail.com>

Linus,

> .. and in fact I think even without those things, you can just make
> the unnamed union have a type name, ie
>
>     struct S {
>        union T {
>            int a;
>        }
>     };
>
> the union T has a typename, but is a unnamed member of struct S. We
> could use "union T" later.

No such luck, not allowed by the C Standard.

6.7.2.1p13
"An unnamed member whose type specifier is a structure specifier with
no tag is called an anonymous structure; an unnamed member whose type
specifier is a union specifier with no tag is called an anonymous union"

But you can do this sort of thing when the type specifier is not anonymous.

-- 
Derek M. Jones                  tel: +44 (0) 1252 520 667
Knowledge Software Ltd          blog:shape-of-code.coding-guidelines.com
Software analysis               http://www.knosof.co.uk

  reply	other threads:[~2014-08-02 18:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-31 18:10 Designated initializers for fields in anonymous structs and unions josh
2014-07-31 18:39 ` Linus Torvalds
2014-07-31 18:50   ` Linus Torvalds
2014-07-31 20:55     ` josh
2014-08-02  8:27     ` Christopher Li
2014-08-02 18:09       ` Christopher Li
2014-08-01  2:19 ` Linus Torvalds
2014-08-01  2:41   ` Linus Torvalds
2014-08-02  1:16     ` Linus Torvalds
2014-08-02  5:16       ` Christopher Li
2014-08-02 18:10         ` Linus Torvalds
2014-08-02 18:31           ` Derek M Jones [this message]
2014-08-02 18:40             ` Christopher Li
2014-08-02 19:53           ` Linus Torvalds
2014-08-02 20:09             ` Linus Torvalds
2014-08-06  9:15             ` Christopher Li
2014-08-01  2:41   ` Josh Triplett

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=53DD2E78.2050609@knosof.co.uk \
    --to=derek@knosof.co.uk \
    --cc=josh@joshtriplett.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --cc=torvalds@linux-foundation.org \
    /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).