Externals

Here is the information you need if you want to call C code, C++ code as well as Java code from your Eiffel code (to call an Eiffel feature from C, C++ or Java see `cecil documentation`).

Below is the current list of SmartEiffel external language specifications.

external "C"

The most common way to call external C code from Eiffel is to use the external "C" feature definition as described in the book "Eiffel The Language". The best is to start to browse examples of the SmartEiffel distribution in directory `tutorial/external/C` where you'll find `external "C", external "C inline", external "C macro"` examples.

external "C++"

The most common way to call external C++ code from Eiffel is to use the external C++ feature definition as described in the book "Eiffel The Language". The best is to start to browse examples of the SmartEiffel distribution in directory `tutorial/external/C++` where you'll find `external "C++"` examples.

external "Java"

A brand new interface to call Java method or Java static method is also available. Obviously, this one is only supported when using the `compile_to_jvm` command (conversely, previous one are only supported when using the `compile_to_c` command). Again, and especially for this brand new one, the best is to start to browse examples of the SmartEiffel distribution in directory `tutorial/external/Java`.

external "SmartEiffel"

This external specification is reserved to the SmartEiffel compiler itself. Do not use it. Such a feature is directly supported both by `compile_to_c` and `compile_to_jvm`. For example, infix "+" of class INTEGER is directly mapped as C '+' by `compile_to_c` and mapped as an `iadd` JVM byte-code by `compile_to_jvm`.

Inlining C Code (or assembly code)

Another way to call C code from Eiffel is to use "c_inline_c" or "c_inline_h" as defined in our GENERAL class. The argument of "c_inline_c" (or "c_inline_h") must always be a manifest string which may contains the C code you want to put in lieu.
Using c_inline_[c/h] also implies you do know exactly the C code SmartEiffel produces. For portability, it is also much better to use previous solutions.
People who tinker with the C code generated by SmartEiffel, not limiting themselves to the Cecil and/or external interfaces, should also read this page about the C code generated by SmartEiffel, Otherwise they might get into trouble.

Copyright © Dominique COLNET and Suzanne COLLIN - <SmartEiffel@loria.fr>
Last modified: Tue Feb 11 12:15:02 CET 2003