[plt-scheme] Re: large blocks inside cstructs
On Dec 18, Dave Herman wrote:
> >> I'm considering creating a small fixed prefix of the sequence of
> >> blocks of size 2^n bytes (say, from _byte up to _kilobyte) and use
> >> the largest chunks possible in the implementation of
> >> define-inline-cstruct.
> >
> > I don't think that this will work right -- I think that the alignment
> > of these blocks will always be 4 bytes.
>
> Does that mean that my current solution is wrong too? I supposedly have
> 260 adjacent byte fields (and ctype-sizeof reports 260 bytes), but are
> they all 4-byte-aligned?
No -- the first one will be, but the others will stick together. But
be careful when you're doing these things. I think that using your
approach, you'll have a problem if you use two fields of (for example)
15 bytes: if it's all translated to bytes, then they'll take a total
of 30 bytes -- but a C compiler will align the second field up a byte.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!