4.1.2 Creating foreign structure types
:type
keyword argument for a given slot in a foreign structure refers to the named slot type that exists at the time the slot is processed, not at the time that the new structure definition is processed. This distinction can lead to some confusion when redefining recursive types. For example, suppose thatfirst
andsecond
are undefined foreign types. The following forms define the foreign typesfirst
andsecond
in terms of one another. Each of these types has three slots:
(def-foreign-struct first (a :type (:pointer second)) (b :type (:pointer first)) (c :type :single-float))If(def-foreign-struct second (x :type (:pointer second)) (y :type (:pointer first)) (z :type :single-float))
second
is redefined as follows, there will be a third foreign type, also namedsecond
, with three slots.(def-foreign-struct second (x :type (:pointer second)) (y :type (:pointer first)) (z :type :double-float))To avoid this outcome, use the function
undefine-foreign-type
onfirst
andsecond
, and then redefine both types.
Generated with Harlequin WebMaker