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 16:47:18 -0500

[re-adding cc: to chicken-users, my fault]

If you merely need the constant values, what you probably want is:

(define c:zero (foreign-value "ZERO" int))
(define c:one (foreign-value "ONE" int))
(define c:two (foreign-value "TWO" int))

define-foreign-enum-type is for automatic conversion between C numeric
enums and Scheme symbolic enums.  It doesn't look like you need that.

On Mon, Jul 26, 2010 at 16:14, Martin DeMello <address@hidden> wrote:
> Right now, just the constant values. All I need is for them to be kept
> in sync with the C enum.
>
> martin
>
> On Tue, Jul 27, 2010 at 2:43 AM, Jim Ursetto <address@hidden> wrote:
>> Are you using the foreign type conversion facilities at all or do you just 
>> need the constant values?
>>
>> On Jul 26, 2010, at 15:20, Martin DeMello <address@hidden> wrote:
>>
>>> On Tue, Jul 27, 2010 at 1:20 AM, Jim Ursetto <address@hidden> wrote:
>>>> 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.
>>>
>>> Thanks. If you're taking feature requests, it would be useful to have
>>> an option to define-foreign-enum-type to create the exportable
>>> bindings automatically too, for use cases like mine (I'm writing
>>> bindings to a C library, so the enums are typically more useful to my
>>> users than they are within the binding code).
>>>
>>> martin
>>
>



reply via email to

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