chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] RE: define-foreign-enum with a typedef


From: Shawn Rutledge
Subject: [Chicken-users] RE: define-foreign-enum with a typedef
Date: Wed, 12 Dec 2007 10:12:04 -0700

So the question still stands - how do you use define-foreign-enum when
the enum doesn't have a name, is only typedef'd?

---------- Forwarded message ----------
From: Jeremy Sydik <address@hidden>
Date: Dec 12, 2007 12:50 AM
Subject: Re: [Chicken-users] define-foreign-enum with a typedef
To: Shawn Rutledge <address@hidden>


Alright, looking at the code I've worked on and the dbus code, I'm
seeing that this works:

typedef enum _DBusBusType
{
  DBUS_BUS_SESSION,    /**< The login session bus */
  DBUS_BUS_SYSTEM,     /**< The systemwide bus */
  DBUS_BUS_STARTER     /**< The bus that started us, if any */
} DBusBusType;

(define-foreign-enum (dbus:bus (enum "_DBusBusType"))
         (dbus:session-bus DBUS_BUS_SESSION)
         (dbus:system-bus DBUS_BUS_SYSTEM)
         (dbus:starter-bus DBUS_BUS_STARTER) )

gets rid of the incomplete type problem.  dbus.h doesn't have the
_DBusBusType declaration
though, so I'll have to leave it to someone else to clarify the proper
solution

--Jeremy



On Dec 12, 2007, at 1:00 AM, Shawn Rutledge wrote:

> Of course BTW I didn't expect it to do anything yet, just compile...
>
> On Dec 11, 2007 11:56 PM, Shawn Rutledge
> <address@hidden> wrote:
>> OK, I'll attach the whole thing; still very small.
>>
>> Thanks for your help.  I'm probably being stupid about something.
>>
>>
>> On Dec 11, 2007 10:49 PM, Jeremy Sydik <address@hidden> wrote:
>>> Hmmm... without a bigger code snip, it's hard to say for certain,
>>> but I
>>> would guess
>>> that somewhere you're declaring a foreign with the C name instead
>>> of the
>>> Scheme one.  Something like
>>>
>>> ;; Incorrect
>>> (define dbus:foo
>>> (foreign-lambda unsigned-int
>>> DBusBusType))
>>>
>>> instead of
>>>
>>> ;; Correct
>>> (define dbus:foo
>>> (foreign-lambda unsigned-int
>>> dbus:bus))
>>>
>>>
>>> As another possibiility, make sure you're quoting the symbols when
>>> you use
>>> them
>>> -- this one bit me a few times.
>>>
>>> --Jeremy
>>>
>>>
>>> On Dec 11, 2007, at 11:37 PM, Shawn Rutledge wrote:
>>> On Dec 11, 2007 10:27 PM, Jeremy Sydik <address@hidden> wrote:
>>> It seems to work for me:
>>>
>>> (pp (dbus:bus->number 'dbus:session-bus))
>>> (pp (number->dbus:bus 1))
>>>
>>> -->
>>>
>>> 0
>>> dbus:system-bus
>>>
>>> How is it failing for you?
>>>
>>> [proton][10:27:21 PM] make
>>> csc -dynamic -I/usr/include/dbus-1.0/ -I/usr/lib/dbus-1.0/include -o
>>> dbus-egg.so dbus.scm -ldbus-1
>>> dbus-egg.c: In function `stub25':
>>> dbus-egg.c:43: error: variable `t0' has initializer but incomplete
>>> type
>>> dbus-egg.c:43: error: conversion to incomplete type
>>> dbus-egg.c:43: error: storage size of 't0' isn't known
>>> *** Shell command terminated with exit status 1: gcc dbus-egg.c -o
>>> dbus-egg.o -c -fno-strict-aliasing -DHAVE_CHICKEN_CONFIG_H -Os
>>> -fomit-frame-pointer -fPIC -DPIC -DC_SHARED -I /usr/local/include
>>> -I/usr/include/dbus-1.0/ -I/usr/lib/dbus-1.0/include
>>> make: *** [dbus-egg.so] Error 1
>>>
>>> Line 43 is:
>>>
>>> enum DBusBusType t0=(enum DBusBusType )C_num_to_int(C_a0);
>>>
>>>
>>




reply via email to

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