[gambit-list] FFI numeric vector lengths

Lassi Kortela lassi at lassi.io
Sun Aug 9 12:39:02 EDT 2020


> You are using the `___U8VECTORLENGTH` macro and friends incorrectly.  They return a fixnum but your `c-lambda`s return `size_t`… so you want to say `___INT(___U8VECTORLENGTH(___arg1))` which converts the fixnum to an `int`, or use `scheme-object` instead of `size_t` as the return type of the `c-lambda`s.

Thanks! I didn't notice the fixnum tagging.

How does one build lists in a c-lambda? This:

(pp ((c-lambda () scheme-object
        "___return(___CONS(___FIX(1), ___CONS(FIX(2), ___NUL)));")))

gives errors about:

/Users/lassi/.local/include/gambit.h:2459:30: error: '___hp' undeclared 
(first use in this function); did you mean '___fp'?
  2459 | #define ___BEGIN_ALLOC_PAIR()___hp[0] = 
___MAKE_HD_WORDS(___PAIR_SIZE,___sPAIR)
       |                              ^~~~~




More information about the Gambit-list mailing list