rawWrite of a struct suggestions

Charles Hixson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Mar 25 11:25:28 PDT 2016


I've got a simple struct:
struct    Chnk
{  ulong        id;
     char[20]    wrd;
     ubyte        length;

    ...    <--various utility functions and constructors
}
That I'm trying to write to a file.  I want to use an unformatted 
read/write because I want this to be a random access file.

But when I try to cast a Chnk to a ubyte[], I get an error, and when I 
try to to!ubyte[] it I get a slightly different error:: Error: template 
instance isRawStaticArray!() does not match template declaration 
isRawStaticArray(T, A...)

I don't want to copy it twice each time I read or write it, as I would 
if, e.g., I used OutBuffer.  How should I approach this?  Do I need to 
use fread/fwrite?  I'm sure I used to be able to pass a pointer and 
length, but I can't find that option anymore.


More information about the Digitalmars-d-learn mailing list