[plt-scheme] C enum syntax

From: dvanhorn at emba.uvm.edu (dvanhorn at emba.uvm.edu)
Date: Sat Jan 25 14:50:14 EST 2003

I've been using the C FFI and handling enumerated constants like so, which seems
to work fine:

   (define some-const ((c-lambda () int "___result = SOME_CONST;")))

But I would rather do something like:

   (define some-const (c-enum "SOME_CONST"))

So I tried:

   (define-syntax (c-enum stx)
     (syntax-case stx ()
       ((_ c)
         ((c-lambda () int 
            (unsyntax (format "___result = ~a;" (syntax c)))))))))

Which is apparently not correct.  Could someone shed some light on what's wrong
with the `c-enum' syntax above?  Also, is there a better approach to enums in


Posted on the users mailing list.