[racket] FFI - static c arrays inside a struct and libgit2 bindings
At Fri, 2 Sep 2011 20:50:52 +0200, Joan Arnaldich wrote:
> In an attempt to learn racket ffi, I've started to work on the
> bindings for the libgit2 library.
>
> I seem to have hit a (small) wall with this struct:
>
> typedef struct git_index_entry_unmerged {
> unsigned int mode[3];
> git_oid oid[3];
> char *path;
> } git_index_entry_unmerged;
>
> Is there a way to declare static C array fields with
> define-cstruct? Couldn't find it in the docs...
> If there isn't, what would be the most common way to tackle this?
> (pointers and ctype-sizeof / ctype-alignof?)
In version 5.1.3 and earlier, you could write
(define-cstruct _git_index_entry_unmerged
([mode0 _uint]
[mode1 _uint]
[mode2 _uint]
[oid0 _git_oid] ; assuming _git_oid is defined
[oid1 _git_oid]
[oid2 _git_oid]
[path _string]))
With the latest development version (or v5.1.3.3 and later), you can
write
(define-cstruct _git_index_entry_unmerged
([mode (_array _uint 3)]
[oid (_array _git_oid 3)] ; assuming _git_oid is defined
[path _string]))