Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cme!durer!hines From: hines@cme.nist.gov (Lynnwood Hines - pdes) Newsgroups: comp.lang.lisp Subject: passing strings from C into Allegro Franz lisp Message-ID: Date: 29 May 91 18:50:07 GMT Sender: news@cme.nist.gov Distribution: comp Organization: National Institute of Standards and Technology Lines: 54 OK, I solved the problem here, and the solution is: C code that creates the string: *************************************************** #include #include char back[] = "Hello from C..."; long lisp_value(); char * fill_string (bindex) int bindex; { printf("C:setting string to: %s\n", back); printf("C:bindex set to: %d\n", bindex); fflush(stdout); strcpy ((char *)lisp_value(bindex)+2, back); printf("C:setting lisp_value to: %s\n", (char *)lisp_value(bindex)); fflush(stdout); return ((char *)lisp_value(bindex)); } ************************************************************ and the lisp side looks like this: (defconstant *msl* 256) (defvar *lsb* (make-string *msl*)) (defvar *lsbi* (ff:register-value *lsb*)) (load "test.o") (ff:defforeign 'fstring :entry-point (ff:convert-to-lang "fill_string") :arguments '(integer) :return-type :lisp) (setq foo (fstring *lsbi*)) Turns out the problem was we had to add 2 to the char * before sending it over due to the length of the string being stored in the first 2 bytes of the string returned by lisp_value. Our docs had told us to use a bunch of elaborate macros in a file called lisp.h (which didn't exist), but it looks like one of the macros did a char* and the other added 2 to the pointer! Just thought this might be of use to others... Lynwood Hines