chicken-users
[Top][All Lists]
Advanced

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

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


From: felix winkelmann
Subject: Re: [Chicken-users] return a pair of ints from a C function?
Date: Sat, 2 Aug 2008 12:20:24 +0200

On Fri, Aug 1, 2008 at 8:15 AM, Shawn Rutledge
<address@hidden> wrote:
>
> This works:
>
> (define g2d_glyphs_baseline (foreign-primitive scheme-object
> ((g2d-glyph-vector glyphs))
>        "C_word* a = C_alloc(C_SIZEOF_PAIR);
>        return(C_pair (&a, C_fix(10), C_fix(256)));" ))
>
> but is there a way to do it in a C source file rather than having to
> write C inside quotes?
>

You can put a C function that looks like this into a separate
file and access it with ##core#primitive:

/* x.c */

#include "chicken.h"

C_word g2d_glyphs_baseline(C_word c, C_word self, C_word k, C_word glyphs)
{
  C_word *a = C_alloc(C_SIZEOF_PAIR);
  C_kontinue(k, C_pair(&a, C_fix(10), C_fix(256)));
}

/* y.scm */

#>
#include "x.h"
<#

(define g2d_glyphs_baseline (##core#primitive "g2d_glyphs_baseline"))


cheers,
felix




reply via email to

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