Haskell FFI: pointer to function inside structure

Say I have this structure in C:

/* C */ struct foo { char *name; int (*links)(foo*); /* ... */ }; 

If I have x :: Ptr Foo , how do I get FunPtr to x links without using castPtrToFunPtr ? I want to avoid this due to a warning in Spells about functions and non-functions having different address ranges (and possibly sizes?), So casting can cause problematic behavior for these platforms.

+4
source share
1 answer

... Good, never mind. :)

If anyone is interested, you can simply use hsc2hss #peek (etc.) to read the field as FunPtr a , and it just works. It seems.

+4
source

All Articles