structs, templates, alias
Ellery Newcomer
ellery-newcomer at utulsa.edu
Sun Apr 25 12:32:19 PDT 2010
On 04/25/2010 02:10 PM, Robert Clipsham wrote:
> On 25/04/10 19:15, Ellery Newcomer wrote:
>> Yeah, that's about what I do. The trouble is getting blit to know which
>> field is the length field. I suppose you could pass an index into the
>> tuple to the substructure. That still wouldn't fix the substructure
>> being able to modify the field length.
>
> I don't know how the input data is formatted, but an array is always in
> the form:
> ----
> struct
> {
> size_t length;
> void* ptr;
> }
> ----
> So it shouldn't be a problem knowing what offset to write the
> length/elements at.
Hmm. Either I'm not understanding you or I didn't explain something clearly.
something like this
struct Rec2{
ushort index;
ushort nparams;
ushort options;
ushort[] params; // this has nparams elements
}
Rec2 rec2 = {index:1, nparams:2, options:~0, params:[4,5]};
would translate to something like
x"01 00 02 00 FF FF 04 00 05 00"
only the elements part of params gets written out, the length part doesn't.
More information about the Digitalmars-d-learn
mailing list