Dan,
You are imagining i am cleverer than I am.
Currently i do:
(define-foreign-record-type (inotify_event "struct inotify_event")
(constructor: make-inotify_event)
(destructor: free-inotify_event)
(unsigned-int32 mask mask)
(unsigned-int32 cookie cookie)
(unsigned-int32 len len)
(unsigned-int32 name name)
)
Obviously name is wrong (except for file names of 2 chars length)
I syntactically don't know how to make the allocated size bigger.
On 21/06/13 06:32, Dan Leslie wrote:
Probably the simplest solution would be to treat it as fixed size and
use the maximum possible size for the object.
From http://linux.die.net/man/7/inotify
Specifying a buffer of size
sizeof(struct inotify_event) + NAME_MAX + 1
will be sufficient to read at least one event.
-Dan
On 6/20/2013 12:58 PM, Geoffrey wrote:
Hi I am trying to declare of variably sized c struct as a foreign
declaration.
The one i am after is:
struct inotify_event
{
int wd;/* Watch descriptor. */
uint32_t mask;/* Watch mask. */
uint32_t cookie;/* Cookie to synchronize two events. */
uint32_t len;/* Length (including NULs) of name. */
char name __flexarr;/* Name. */
};
Note that name field is variably sized. I believe in C you would allocate a
larger block of memory and then cast it to (inotify_event*).
By the skills of copy and paste i can do fixed size,and i can do a blob. But
not a variable struct.
Some help would be appreciated.
Thanks
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users