Sat Mar 26 10:38:43 EDT 2011

Racket FFI

I'm having some trouble getting the libusb.ss code back online after
upgrade to Racket 5.1

Basically, I forgot everything ;)

I've reconstructed the following basic example:

#lang scheme/base
(require scheme/foreign)


(define-cstruct _a
  ((next _a-pointer/null)))

The thing to note is that recursive data structures always need the
"`-pointer" or "-pointer/null" suffix.

So I wonder, how did this work before?

Oki, I see the problem:

(define-cstruct _usb-device
  ([next         _usb-device-pointer/null]
   [prev         _usb-device-pointer/null]
   [filename     _path-type]
   [bus          _usb-bus-pointer-dummy]
   [descriptor   _usb-device-descriptor]
   [config       (_cpointer _usb-config-descriptor)]
   [dev          _pointer]
   [devnum       _uint8]
   [num_children _uint8]
   [children     (_cpointer _usb-device-pointer)]))

I get the message that the identifier `usb-device-config' is already
defined.  The reason is that `define-cstruct' now defines accessors
for the struct members, and from the "descriptor" field it generates
the clashing name.