chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] using constants from define-foreign-enum-type via a


From: Jim Ursetto
Subject: Re: [Chicken-users] using constants from define-foreign-enum-type via a module
Date: Mon, 26 Jul 2010 14:50:59 -0500

The right way is to use include, foreign variables are not visible outside the 
compilation unit they are declared in.

Alternatively if you want a user accessible interface to the constants, and do 
not want to use the conversion procedures, use regular old define and export 
that binding: 

(define zero c:zero) ; then export zero

In short, if this is for internal use, use include. If it is for users, write a 
nice API for them.


On Jul 26, 2010, at 14:27, Martin DeMello <address@hidden> wrote:

> Here's some code I'm using to test various module features (attached,
> and at http://github.com/martindemello/test-chicken-modules)
> 
> In cprog-binding.scm, I define a binding to a C enum via:
> 
> (define-foreign-enum-type (ccount int)
>                          (ccount->int int->ccount)
>                          (c:zero ZERO)
>                          (c:one ONE)
>                          (c:two TWO)
>                          (c:three THREE))
> 
> This works if I (include "cprog-binding") directly in a scheme file
> (see "direct-load.scm"). However, if I want to include it in a module,
> then import the module, I cannot access the enum constants, though I
> can access ccount->int and int->ccount (see "test.scm"). What's the
> right way to do this?
> 
> martin
> <test-chicken-modules.tgz>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-users



reply via email to

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