[Haskell-iPhone] General FFI Questions

Stephen Blackheath [to GHC-iPhone] likeliest.complexions.stephen at blacksapphire.com
Fri Jan 3 23:27:40 UTC 2014


Schell,

Take a look at my Storable instance for SockAddrBTH here:

https://github.com/the-real-blackh/simple-bluetooth/blob/master/Network/Bluetooth/Device.hsc

Using .hsc files gives you get the offset into the structure like this:

  p `plusPtr` (#const offsetof(struct sockaddr_rc, rc_bdaddr))

#include <stddef.h> to give you offsetof.

Quite a useful trick.


Steve

On 04/01/14 08:41, Schell Scivally wrote:
> I'm having a hard time unmarshalling a c struct into a haskell record.
> Does anyone have a good link that talks about unmarshalling nested c
> structs? Is this common or should I just forget about it?
> 
> -- 
> Schell Scivally
> http://blog.efnx.com
> http://github.com/schell
> http://twitter.com/schellsan
> 
> 
> _______________________________________________
> iPhone mailing list
> iPhone at haskell.org
> http://www.haskell.org/mailman/listinfo/iphone
> 


More information about the iPhone mailing list