public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Pilcher <arequipeno@gmail.com>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Flexible array member initializers
Date: Wed, 08 Jan 2014 21:49:00 -0000	[thread overview]
Message-ID: <52CDC7C8.5070804@gmail.com> (raw)
In-Reply-To: <CAH6eHdQuGyW+T4yjpyjNHbi6akf9xfHezSHqvwnqF7NgDaE6nw@mail.gmail.com>

On 01/08/2014 04:42 PM, Jonathan Wakely wrote:
>> #define SHORT_BYTES(s)  { ((s) & 0xff), (((s) >> 8) & 0xff) }
>>
>> struct foo {
>>      size_t value_size;
>>      unsigned char value[];
>> };
>>
>> static struct foo foo_short = {
>>      .value_size = sizeof(short),
>>      .value      = SHORT_BYTES(513),
>> };
>
> Where do you think those two bytes are meant to be stored?
>

Maybe I don't understand your question, but the two bytes that make up
the short get stored in the "value" element (as an array of 2 unsigned
characters).

That said, since I've realized that this simply isn't going to work for
anything but integer types, I'm going to give up on the flexible array
member for this particular use.

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
"If you're going to shift my paradigm ... at least buy me dinner first."
========================================================================

  reply	other threads:[~2014-01-08 21:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08  5:13 Ian Pilcher
2014-01-08  8:59 ` Jonathan Wakely
2014-01-08 20:41   ` Ian Pilcher
2014-01-08 21:00     ` Marc Glisse
2014-01-08 21:46       ` Ian Pilcher
2014-01-08 21:43     ` Jonathan Wakely
2014-01-08 21:49       ` Ian Pilcher [this message]
2014-01-08 22:21         ` Jonathan Wakely
2014-01-08 23:23     ` Ángel González
2014-01-11  2:03       ` Ian Pilcher

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=52CDC7C8.5070804@gmail.com \
    --to=arequipeno@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jwakely.gcc@gmail.com \
    /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).