[cffi-devel] char** ??

Stephen Compall s11 at member.fsf.org
Wed Mar 15 19:17:59 UTC 2006


On Wed, 2006-03-15 at 19:28 +0100, Goenninger, Frank wrote:
> extern void glutInit(int *argcp, char **argv);
> 
> 1. Do I have to define a new type as Integer Pointer ? Same also for  
> char ** ?

No, pointers aren't typed in the CFFI type system.

> 2. How do I avoid defining new types while still being able to define  
> this function via defcfun ?

You don't have to; just use pointers.  The type-defining system is there
strictly for when you want its fancy translating capabilities.

> Or, in other words, how would you define this function with defcfun ??

(defcfun "glutInit" :void
  (argc :pointer)
  (argv :pointer))

I'll leave definition of an `init-glut' wrapper function for this as an
exercise for the reader.  You could also just write an `init-glut' that
simply uses foreign-funcall on glutInit, but that is a matter of
personal preference and degree of care about the platforms where
foreign-funcall doesn't work.

The tutorial
(http://common-lisp.net/project/cffi/manual/html_node/Tutorial.html)
includes in-depth treatment of the type system.

-- 
Stephen Compall
http://scompall.nocandysw.com/blog




More information about the cffi-devel mailing list