[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] how to declare foreign variably size structs?

From: Dan Leslie
Subject: Re: [Chicken-users] how to declare foreign variably size structs?
Date: Thu, 20 Jun 2013 13:32:48 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

Probably the simplest solution would be to treat it as fixed size and use the maximum possible size for the object.


Specifying a buffer of size

sizeof(struct inotify_event) + NAME_MAX + 1

will be sufficient to read at least one event.


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.


Chicken-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]