From: Hisao Kuroda
Subject: CMUCL: How can I pass the array to C subroutine ?
Date:
Message-ID: <508@msisun.msi.co.jp>
Hello.
I am a CMU-CL user.
I'm trying to pass the pointer-to-array to C subroutine.
Followings are my code.
--- Lisp code
(ext:load-foreign '("cmu-c.o") '("-lc")) ; Load the C code above.
(ext::def-c-array ar single-float)
(ext::def-c-pointer *ar ar)
(ext::def-c-routine ("foo" foo) (void)
(n int)
(f *ar))
(defun call-foo ()
(foo 3 (make-ar 3)))
--- C code
void foo (n, ar)
int n;
float *ar;
{
int i;
for (i=0; i<n; i++)
printf("ar[%d]=%f\n",i,ar[i]);
}
---
and the result is
% lisp
CMU Common Lisp 15e, running on dwarf
Hemlock 3.5 (15e), Python 1.0(15e), target SPARCstation/Sun 4
Send bug reports and questions to ··········@cs.cmu.edu.
* (load "cmu-c")
;;; Running library:load-foreign.csh...
;;; Loading object file...
;;; Parsing symbol table...
Warning:
"_etext" moved from #x0002CA58 to #x00C00080.
Warning:
"_edata" moved from #x0003DC38 to #x00C00090.
Warning:
"_end" moved from #x000482D8 to #x00C00090.
;;; Done.
T
* (call-foo)
Error in "The Undefined Function": the function C::%ALIEN-ACCESS is undefined.
Restarts:
0: Return to Top-Level.
Debug (type H for help)
(DEBUG::DEBUG-LOOP)
0]
---
Does anyone tell me what is wrong ?
Thank you.
--
Mathmatical Systems Institute Inc.
6F AM BLDG. 2-5-3 Shinjuku, Shinjuku-Ku, Tokyo Japan
E-mail : ······@msi.co.jp (Kuroda,Hisao)
# Everybody's got something to hide except me and my //GS. #