chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] return a pair of ints from a C function?


From: Shawn Rutledge
Subject: [Chicken-users] return a pair of ints from a C function?
Date: Thu, 31 Jul 2008 00:37:24 -0700

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);
}

to be called like this

( (foreign-lambda scheme-object "g2d_glyphs_baseline" g2d-glyph-vector) glyphs)

It compiles and I get weird results at runtime, so obviously am not
building the cons cell correctly.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]