More C interfacing issues

Sven Panne Sven.Panne at informatik.uni-muenchen.de
Tue Jul 2 13:48:20 EDT 2002


Alastair Reid wrote:
 > [...] 3 wrapper functions more or less like this:
 >
 >   static int x;
 >   static int y;
 >   void wrap_getyx(WINDOW *win) { getyx(win,x,y); }
 >   int getx(void) { return x; }
 >   int gety(void) { return y; }
 > [...]

Uh, oh! Don't even try this if you ever want to be thread-safe!   :-}

 > or what GreenCard used to do which is more or less [...]

Much better, and a two-element array would be even easier (see the FFI's
marshaling utitlities) and more portable (structure layout is an ABI issue)
here.

Cheers,
    S.




More information about the FFI mailing list