[racket] Sending a cvector to foreign functions.

From: Lewis (lewis1711 at gmail.com)
Date: Mon Jan 24 00:50:32 EST 2011


I am trying to send a racket cvector to a C function in a lib I a
writing. The C function in question has the prototype

void render(int x_camera, int y_camera, Visual pc, Tile **world);

The important bit is the last argument, Tile **world. I have
registered this in racket as

(define render
   (get-ffi-obj "render" cio
                   (_fun _int _int _visual (_ptr i _cvector) -> _void)))

Unfortunately, whenever I try and send a cvector of type Tile into it,
I get the error

SIGSEGV MAPERR si_code 1 fault on addr 0x100004

I am confident it is due to this, since it executed flawlessly until I
expanded the function to receive the cvector.

Can anyone point out where I might be going wrong? Will be happy to
paste the whole thing up in gist or similar.


Posted on the users mailing list.