Minor issue - zero-length fixed size arrays in variable-sized structs..
Joakim via Digitalmars-d
digitalmars-d at puremagic.com
Sun Mar 29 12:47:42 PDT 2015
On Wednesday, 8 July 2009 at 22:55:47 UTC, Jarrett Billingsley
> I noticed in the spec on arrays that "A [fixed-size] array with
> dimension of 0 is allowed, but no space is allocated for it.
> useful as the last member of a variable length struct.." This
> like C99's "flexible array members," where a struct can have an
> as its last element that isn't given a size, specifically for
> variable-sized structs.
> Well, the issue with a zero-length fixed-size array is that..
> uh, you
> can't access anything out of it. The compiler disallows any
> of a zero-length array with constant indices, and at runtime,
> accesses caught by the array bounds checking. Weirder still,
> the .ptr
> of any zero-length array is always null, so you can't even do
> like "arr.ptr = x;" (which would be perfectly acceptable in
> Just a silly issue.
Just thought I'd mention that this works now, since this is the
only forum thread that mentions working with C's flexible array
members. You simply define a zero-length array and then access
it using .ptr, as in this C binding and example program I
More information about the Digitalmars-d