[Openmcl-devel] Question about foreign-functions

Camille Troillard tuscland at mac.com
Thu Nov 20 16:16:12 PST 2003


Hello OpenMCL,


I am Camille, and I am new to this list.
I am building a web server application with PortableAllegroServe with 
webaction and CL-SQL with OpenMCL on Mac OS X 10.3.

I am getting some problems with FFI :  Here is a code sample that 
doesn't work.  It is very likely that I am wrong, because I just start 
writing Lisp programs.

This function is supposed to call the function "stat", access the 
st_ino field of the structure  and return the result which is 
(supposedly) an int.


(defun filesys-inode (path)
   (let ((checked-path (probe-file path)))
     (cond (checked-path
	   (rlet ((pstat (:* (:struct stat))))
		 (with-cstrs ((str (namestring checked-path)))
		   (#_stat str pstat))
		 (pref pstat :stat.st_ino)))
	  (t (error "path ~s does not exist" path)))))

If I call this function I get this error :

 > Error in process listener(1): value 0 is not of the expected type 
LIST.
 > While executing: "Unknown"

If I put a "print" form around the pref call, the result I correctly 
printed on the standard output and then the error arises.  A look to 
the backtrace confirms that the error occurs outside of the 
"filesys-inode" call.

If I replace rlet with rletz I get the following compilation error 
which I don't understand:

 > Error in process listener(1): While compiling FILESYS-INODE :
 >                               #1=(PSTAT (:* (:STRUCT STAT))) is not a 
symbol or lambda expression in the form (#1#) .


I think that I must pass #_stat a reference to a stack allocated 
structure.
The problem is that:
1.  I don't know how to pass a reference to a stack allocated object to 
#_stat
2.  I don't know how to declare a stat structure object because if I 
try :

	(rlet ((pstat (:struct stat)))
		...

I get a compilation error.




Thanks in advance for any help!

Kind Regards,
Camille Troillard



More information about the Openmcl-devel mailing list