[Openmcl-devel] Objc typedef mappings
Gary Byers
gb at clozure.com
Sun Jan 23 14:59:43 PST 2005
On Sun, 23 Jan 2005, todd ingalls wrote:
> Hello,
> I have a quick question. Is it possible to use def-foreign-type to
> either make an array of a user defined type or use another user defined
> type in another struct definition. For example, the following doesn't
> work. Should it? Is there another way to do this?
Structure names and type names are maintained separately. (This is
close to how C handles things; from what I understand, C++ handles
structure and type names as being in the same namespace.)
>
>
> (def-foreign-type nil (:struct foobar (a :double-float) (b (:signed
> 32))))
>
This defines a "structure tag" named FOOBAR; it doesn't define a
type. (You can refer to the type named by that structure tag
as (:STRUCT FOOBAR)).
> (def-foreign-type foobar-array-4 (:array :foobar 4))
>
> => Unknown foreign type: FOOBAR
>
>
> -------
>
> (def-foreign-type nil (:struct foobar (a :double-float) (b (:signed
> 32))))
> (def-foreign-type nil (:struct baz (c (:unsigned 32)) (d :foobar)))
>
> => Unknown foreign type: FOOBAR
>
Yep, it's not defined.
This distinction might be a little easier to keep in mind (you'd
at least be reminded of it more often ...) if RLET and a few other
things were less DWIMy about it. You -can- use a structure tag in
place of a type name in RLET, and it will guess what you mean.
If any of this is unclear:
(def-foreign-type nil (:struct foobar (a :double-float) (b :int)))
is analogous to the C definition:
struct foobar {
double a;
int b;
};
whereas
(def-foreign-type foobar (:struct foobar (a :double-float) (b :int)))
is analogous to
typedef struct foobar {
double a;
int b;
} foobar.
>
> Thanks for any help.
>
>
>
>
>
> Todd Ingalls
> Assistant Research Professor
> Arts, Media and Engineering Program
> Arizona State University
> http://ame2.asu.edu/faculty/todd
More information about the Openmcl-devel
mailing list