To return fixnums, you can do:
C_word g2d_glyphs_baseline(struct G2dGlyphs* glyphs)
{
C_word* a = C_alloc(C_SIZEOF_PAIR);
C_return(C_pair (&a, C_fix(10), C_fix(256)));
}
To return a pair of flonums (which is what you are doing with
C_int_to_num), you need to allocate memory for the numbers thusly:
C_word g2d_glyphs_baseline(struct G2dGlyphs* glyphs)
{
C_word* lst = C_alloc(C_SIZEOF_PAIR);
C_word *a, *b;
a = C_alloc (C_SIZEOF_FLONUM);
b = C_alloc (C_SIZEOF_FLONUM);
C_return (C_pair (&lst, C_int_to_num (&a, 10), C_int_to_num (&b, 256)));
}
"Shawn Rutledge" <[EMAIL PROTECTED]> writes:
> OK dumb question time again: I'm trying to return a pair of fixnums
> from a C function.
>
> C_word g2d_glyphs_baseline(struct G2dGlyphs* glyphs)
> {
> C_word* a = C_alloc(C_SIZEOF_PAIR + 8);
> C_return(C_pair (&a, C_int_to_num(&a, 10), C_int_to_num(&a, 256)));
> }
>
> or maybe
>
> C_word g2d_glyphs_baseline(struct G2dGlyphs* glyphs)
> {
> C_word* c_ret = C_alloc(C_SIZEOF_PAIR);
> C_word* a = c_ret;
> C_int_to_num(&a, 10);
> C_int_to_num(&a, 256);
> C_return(*c_ret);
> }
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users