From: Joe Buck <jbuck@synopsys.COM>
To: gandalf@winds.org (Byron Stanoszek)
Cc: gcc@gcc.gnu.org
Subject: Re: Feature-request: Possibility of transparent unions in structs
Date: Mon, 27 Mar 2000 09:36:00 -0000 [thread overview]
Message-ID: <200003271735.JAA20920@atrus.synopsys.com> (raw)
In-Reply-To: <Pine.LNX.4.21.0003242307500.16140-100000@winds.org>
> The question: Is there a way to make the union identifier transparent to the
> structure, such that the members of the union can be referenced from the
> context of the structure?
In C++, there is. It's called anonymous unions. For your example, you
would write
struct foo {
int type;
union {
int id;
int *data;
char *string;
}
};
and then, given
foo *bar;
you can write bar->id, bar->data, bar->string, bar->type.
> Can anyone tell me if this feature exists currently in GCC (as a C extension),
> or if possible, can be added to gcc 2.96 / 3.0?
It does not exist as a C extension. I'm not convinced that it is a good
idea to move C++ features into the C front end as extensions on an ad hoc
basis, though I suppose some folks think we set a precedent when C++
comments were allowed.
prev parent reply other threads:[~2000-03-27 9:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-24 20:08 Byron Stanoszek
2000-03-25 9:12 ` Mumit Khan
2000-03-27 9:36 ` Joe Buck [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=200003271735.JAA20920@atrus.synopsys.com \
--to=jbuck@synopsys.com \
--cc=gandalf@winds.org \
--cc=gcc@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).