[gambit-list] working with ___arg* variables in c interface

James Long longster at gmail.com
Sun Sep 9 03:08:31 EDT 2007


In a c-lambda, what are the types of the argument variables ___arg1,
___arg2, and so on?  It seems like they are statically resolved to the
types I passed in to the c-lambda, and everything happens that I
expect to happen:

(define %%addOne
  (c-lambda (int) int "___result=___arg1+1;"))

(display (%%addOne 10))

This correctly prints out 11, and other various operations on pointers
seemed to work too.  For example, if 'ctx' is a structure with a 'id'
field, and 'ctxp' is defined as (pointer ctx), the following function
works fine:

(define %%useCtx
  (c-lambda (ctxp) int "___result=(*___arg1).id;"))

Basically, my question is when do I need to use ___CAST on the
argument variables?  Is it something I should be doing most of the
time for safety, to suppress warnings or for some other reason?  Or is
it something done in a special case I haven't encountered yet?  I've
seen it done in other gambit FFI's and I'm wondering if the other was
just paranoid or something (and if I should be).



More information about the Gambit-list mailing list