[Openmcl-devel] problem building FFI files

Kaveh Kardan kaveh at hawaii.edu
Tue May 30 18:51:09 PDT 2006


I'm setting up the process for connecting OpenMCL to some C libraries.

I manage to call the C functions in the following manner:

--

(external-call "_bz_vec_test" :void)

--

I have installed h-to-ffi.sh and run it on a simple .h file:

--

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

typedef struct {
   union {
     struct {
       float x, y, z, w;
     };
     float vec[4];
   };
} bz_vec;
bz_vec *bz_make_vec();
void bz_print_vec(bz_vec *v);
void bz_vec_test();

--

The script parses the contents of the included system .h files as  
well, resulting in a very large .ffi file.  The relevant portion of  
the file seems to be:

--

(struct ("" 0)
"444_/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.h"
(("x" (field (float ()) 0 4))
   ("y" (field (float ()) 4 4))
   ("z" (field (float ()) 8 4))
   ("w" (field (float ()) 12 4))))
(union ("" 0)
"445_/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.h"
(("" (field (struct-ref "444_/Users/kaveh/Development/bronze2/build/ 
Development/Bronze.framework/Headers/bz_vec.h") 0 16))
   ("vec" (field (array 4 (float ())) 0 16))))
(struct ("" 0)
"447_/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.h"
(("" (field (union-ref "445_/Users/kaveh/Development/bronze2/build/ 
Development/Bronze.framework/Headers/bz_vec.h") 0 16))))
(type ("/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.h" 12)
"bz_vec"
(struct-ref "447_/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.h"))
(function ("/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.h" 14)
"bz_make_vec"
(function
   ((void ()))
   (pointer (typedef "bz_vec"))) (extern))
(function ("/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.h" 15)
"bz_print_vec"
(function
   ((pointer (typedef "bz_vec")) )
   (void ())) (extern))
(function ("/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.h" 17)
"bz_vec_test"
(function
   ((void ()))
   (void ())) (extern))

--

When I try to parse the file, I get an error:

CL-USER> (ccl::parse-standard-ffi-files "bronze")
#P"/Applications/CommonLisp/ccl/darwin-headers/bronze/C/Users/kaveh/ 
Development/bronze2/build/Development/Bronze.framework/Headers/ 
bz_vec.ffi" ...


value #<Unbound> is not of the expected type (OR STRING SYMBOL  
CHARACTER).
    [Condition of type TYPE-ERROR]

Restarts:
   0: [ABORT-REQUEST] Abort handling SLIME request.
   1: [ABORT-BREAK] Reset this process
   2: [ABORT] Kill this process

Backtrace:
   0: (STRING 'NIL)
   1: (CCL::STRING-START-END "__int8_t" #<Unbound> 0)
   2: (STRING= "__int8_t" #<Unbound>)
   3: (CCL::%HASH-PROBE #<HASH-TABLE :TEST STRING= size 0/60  
#x87F1FBE> 'NIL #<HASH-TABLE-VECTOR  #x87F202E>)
   4: (GETHASH "__int8_t" 'NIL "__int8_t")
   5: (CCL::FIND-OR-CREATE-FFI-TYPEDEF ':TYPE)
   6: (CCL::PROCESS-FFI-TYPEDEF '(:TYPE ("/usr/include/ppc/_types.h"  
31) "__int8_t" (:SIGNED-CHAR NIL)))
   7: (CCL::PARSE-FFI #P"/Applications/CommonLisp/ccl/darwin-headers/ 
bronze/C/Users/kaveh/Development/bronze2/build/Development/ 
Bronze.framework/Headers/bz_vec.ffi")
   8: (CCL::PARSE-STANDARD-FFI-FILES "bronze")
   9: (CCL::CALL-CHECK-REGS 'CCL::PARSE-STANDARD-FFI-FILES)

--

Anyone have any ideas what I'm doing wrong?


Regards,

Kaveh

Kaveh Kardan                 Chief Technologist
kaveh at hawaii.edu             Academy for Creative Media
(808)956-5302                University of Hawaii





More information about the Openmcl-devel mailing list