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

Christian Jaeger christian at pflanze.mine.nu
Sun Oct 14 19:22:59 EDT 2007


James Long wrote:
> 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).
>   

I don't see any reason to use such casts (if the types are already what 
you want).

___CAST is just a macro expanding to a C cast btw, I think Marc 
introduced it because it is easier to search for in the sources (for 
when you want to get rid of them or find insecure places).

I'm only using casts for hackery on the Gambit data types (e.g. treating 
pointers as fixnums), or turning the body of a homogenous vector which 
has been passed as scheme-object into a C vector (for using the C array 
access syntax) (e.g. (##c-code "char *foo= 
___CAST(char*,___BODY(___ARG1)); .. foo[i]= ..." ...)).

Christian.




More information about the Gambit-list mailing list