[Openmcl-devel] How do I initialize an array of structs? (FFI)

David Steuber david at david-steuber.com
Sat Jan 8 08:17:13 UTC 2005


Give this C fragment:

EventTypeSpec moonSpec[] = {{kEventClassCommand, kEventCommandProcess},
   {kEventClassWindow, kEventWindowClose}};

How do I initialize moonspec in the following rlet?

   (rlet ((nibref :<ibn>ib<r>ef)
          (mainspec :<e>vent<t>ype<s>pec
                    :event<c>lass #$kEventClassCommand
                    :event<k>ind #$kEventCommandProcess)
          (moonspec (:array :<e>vent<t>ype<s>pec 2)))
     ...)

I tried doing it in the rlet until I found this:

" When the type is an array,  initforms  may  not be provided, because  
make-record   cannot initialize its values.  make-record   is also 
unable to initialize fields of a  struct   which are themselves   
struct   s. The user of   make-record   should set these values  by 
another means."

However, other means were not specified.  I haven't been able to tell 
what to pass to pref.

TIA




More information about the Openmcl-devel mailing list