chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] define-foreign-type


From: felix winkelmann
Subject: Re: [Chicken-users] define-foreign-type
Date: Mon, 31 Oct 2005 07:44:31 +0100

On 10/29/05, Pupeno <address@hidden> wrote:
> Hello, I have a file named glib.c that contains:
> (declare (unit glib))
> #>
> #include <glib.h>
> <#
> (define-foreign-type gpointer "gpointer")
>
> I compile that to a .c and then to a .o.
> I have another file that uses gpointer, I first tried
> (declare (uses glib))
> but it didn't work:
> chicken gtkhello.scm -output-file gtkhello.c
> compiling `gtkhello.scm' ...
> generating `gtkhello.c' ...
> Error: illegal foreign type `gpointer'
>
> So I changed it to (include "glib") and I still get the same error. What am I
> missing ?

Foreign-type declarations are only visible in the currently compiled
file, and thus must be included.

To do anything useful with a value, chicken must know it's fundamental
type. In the case above, gpointer is opaque to chicken: it could be a structure,
or a primitive type, or whatever. In this case, you want it to be treated
like a pointer, and you must tell the compiler about it.
One solution would be:

(define-foreign-type gpointer (pointer void))


cheers,
felix




reply via email to

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