[Ecls-list] Tighter c/c++ integration, toplevel inline c/c++ code ???

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Mon May 3 14:19:57 UTC 2010


On Mon, May 3, 2010 at 4:05 PM, Seth Burleigh <seth at tewebs.com> wrote:

> How is one supposed to tell the compiler about the function, or in
> general any class, class method, structure, etc?
>

Normally one has a C/C++ library with headers that one includes in the
source. The compiler reads the headers (because you have included them) and
then infers the types and functions that are defined in the library. Then
the library is passed to ECL as an argument (see BUILDER description in the
manual) and the linker makes the association such that the compiled code can
call the function

What you intended could not work because your function foo() only existed in
memory. There was no header that could be reused by other files and no file
to be linked against.

What my previous messages implied was the following:

* If you are prototyping classes and functions then define them in the same
file where they are going to be used. Compile, load and that is all.

* If the use your prototypes is going to span multiple lisp files then
create a C/C++ library. Compile and link the FASL files against it and
you're done.

* If you do not feel comfortable with C/C++ please use CFFI and follow the
guidelines there. C-INLINE and CLINES imply some knowledge of how linking
and loading and compiling phase are implemented. CFFI has a different
workflow in which it starts from previously built shared libraries and
everything is simpler that way.

Juanjo

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://tream.dreamhosters.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20100503/9c0d4229/attachment.html>


More information about the ecl-devel mailing list