[Ecls-list] Wrapping C++ constants...

Dietrich Bollmann dietrich at formgames.org
Thu Jul 11 11:26:11 UTC 2013


Hi,

I want to wrap a pointer to a C++ constant into a lisp constant.

The following

  (defconstant +xy-plane+
    (ffi:c-inline () () :pointer-void "(void *) &ON_xy_plane" :one-liner t))

results in this error:

  ;;; Error:
  ;;;   in file rhino-lisp-api.lisp, position 7235
  ;;;   at (DEFCONSTANT +xy-plane+  ...)
  ;;;   * The form (PROGN (SI:*MAKE-CONSTANT '+xy-plane+  (FFI:C-INLINE NIL
NIL :POINTER-VOID "(void *) &ON_xy_plane" :ONE-LINER T))
(SI::REGISTER-GLOBAL '+xy-plane+ )) was not evaluated successfully.
  ;;; Error detected:
  ;;; The special form c-inline cannot be used in the interpreter: (NIL NIL
POINTER-VOID (void *) &ON_xy_plane ONE-LINER T)An error occurred during
initialization:
  COMPILE-FILE-ERROR while
  compiling #<cl-source-file "rhino-lisp-api" "rhino-lisp-api">.
  NMAKE : fatal error U1077:
'C:\Users\dietrich\home\cs\lang\lisp\ecl\64\git\install\ecl.exe' : return
code '0x1'
  Stop.

So I am currently using a function

  (defun get-xy-plane ()
    (ffi:c-inline () () :pointer-void "(void *) &ON_xy_plane" :one-liner t))

and later

  (defconstant +xy-plane+ (get-xy-plane))

But this - at least to me - looks kind of unnecessarily cumbersome...

Is there a better way to wrap a pointer to a constant from lisp?

Thanks,
Dietrich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20130711/a553939d/attachment.html>


More information about the ecl-devel mailing list