[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Basic FFI Principle in Chicken
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] Basic FFI Principle in Chicken |
Date: |
Sat, 7 Sep 2013 12:52:08 +0200 |
User-agent: |
Mutt/1.4.2.3i |
On Sat, Sep 07, 2013 at 12:48:27PM +0200, Kristian Lein-Mathisen wrote:
> Note that this may not be a good idea if your struct members are just using
> "int" because you wouldn't know if it's a s32vector or a s64vector. Also,
> your foreign-type would go from (pointer (struct "color")) to a
> u32vectorwhich means you may have to cast it to a (struct
> color*) in C. However, it does make extracting the individual
> color-components much easier than having to work with raw blobs.
>
> Because size of an "int" can generally be either 32 or 64-bit depending on
> your architecture, the srfi-4 vectors are possible better suited for floats
> and doubles where the sizes are all set. It's worth knowing about them
> though.
Good call! There's also the bitstring egg which makes destructuring
blobs into component values pretty easy as well.
Cheers,
Peter
--
http://www.more-magic.net