[Ecls-list] (and defconstant ffi:c-inline)
mm_lists at pulsar-zone.net
Fri Apr 2 05:40:18 UTC 2010
On Thu, 1 Apr 2010 23:29:37 -0400
Matthew Mondor <mm_lists at pulsar-zone.net> wrote:
> Any suggestion or trick which would allow to define CL constant
> litterals deriving from a C constant, which would not have to lookup
> globals, so that I could fix my DEFINE-C-CONSTANTS macro to use it?
> I admit being relatively new to the various CL environments and could
> very well be missing something obvious.
I guess that another option is to use something like
(defmacro with-c-constants (constants &body body)
(destructuring-bind (symbol constant) c
(ffi:c-inline () () :int ,constant :one-liner t))))
, at body))
(defun bar ()
(with-c-constants ((o-rdonly "O_RDONLY")
(format t "~A ~A~%" o-rdonly o-creat)))
And optionally provide a macro like WITH-FCNTL-CONSTANTS and other
categories using predefined lists, although unfortunately this would
introduce some extra redundancy...
More information about the ecl-devel