[Ecls-list] Embedding ECL library in C program

Goffioul Michael goffioul at imec.be
Tue Sep 4 14:23:27 UTC 2007


> I'm trying to build a simple "hello world"-like example, but 
> not doing very well so far.
> Here is my C code:
> 
> //prog_msg.c
> 
> #include <stdio.h>
> #include <ecl/ecl.h>
> 
> int main(int argc,char** argv)
> {
>   cl_object res;
>   cl_boot(argc,argv);
> 
>   res=eval("(get-msg-text)");
>   printf("%s",(char*)res->string.self);
>   cl_shutdown();
>   return 0;
> }
> 
> and ECL library code:
> 
> //test.lisp
> 
> (defpackage "TEST"
> (:use "COMMON-LISP")
> (:nicknames "TEST")
> (:export "GET-MSG-TEXT"))
> 
> (in-package test)
> 
> (defun get-msg-text()
> (values "Hello from ECL!"))
> 
> I'm getting this error in the first step of the building process:
> 
> $ gcc -I/usr/share/lib/ecl -c prog_msg.c
> prog_msg.c: In function 'main':
> prog_msg.c:9: warning: assignment makes pointer from integer 
> without a cast
> prog_msg.c:10: error: 'union cl_lispunion' has no member 
> named 'string'
> 
> What am I doing wrong?

Look at object.h header. Recent ECL version uses "base_string"
field. "string" field is only defined if unicode support is builtin.

However, looking at your code, I'm afraid you'll get some other
errors. For instance, nothing tells ECL to load test.lisp, so
evaluating (get-msg-text) will probably produce and error.

Michael.




More information about the ecl-devel mailing list