[prev in list] [next in list] [prev in thread] [next in thread]
List: racket-users
Subject: [racket] handling "private" objects in FFI
From: mflatt () cs ! utah ! edu (Matthew Flatt)
Date: 2011-03-20 12:18:48
Message-ID: 20110320121906.A16E56500AC () mail-svr1 ! cs ! utah ! edu
[Download RAW message or body]
At Sun, 20 Mar 2011 08:41:50 +0100, "keydana at gmx.de" wrote:
> I wonder how to handle
> composite objects (structs) returned by a library function that have
> themselves composite objects as fields, but these objects in turn are
> considered to be "private", as seen by them being declared like so:
>
> typedef struct xy xy;
If the shape of `struct xy' isn't exposed, then,
struct something_else {
....
xy an_xy;
....
};
isn't allowed in C. The layout of `struct' fields must be known at the
declaration.
So, either the shape of `struct xy' must be exposed before the
declaration of `struct something_else', or (more commonly) uses of `xy'
are indirect through a pointer. For example, if `something_else' is
struct something_else {
....
xy * an_xy;
....
};
then at the FFI level, you can treat the `an_xy' as a `(_cpointer 'xy)'
or just `_pointer'.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic