mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-08 07:42:33 +01:00
Author:halw
Date:2008-10-02T21:44:24.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@68 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -1,33 +1,5 @@
|
||||
[[Property:title|CECIL Reference]]
|
||||
[[Property:weight|4]]
|
||||
[[Property:uuid|20ca6ef1-0d26-a556-955c-96bed93dfdfb]]
|
||||
Index of CECIL features
|
||||
* [[Reference for `RTMS'|RTMS()]]
|
||||
* [[Reference for `attribute_exists'|attribute_exists()]]
|
||||
* [[Reference for `eif_adopt'|eif_adopt()]]
|
||||
* [[Reference for `eif_attribute'.|eif_attribute()]]
|
||||
* [[Reference for `eif_attribute_type'|eif_attribute_type()]]
|
||||
* [[Reference for `eif_bit_function'|eif_bit_function()]]
|
||||
* [[Reference for 'eif_boolean_function'|eif_boolean_function()]]
|
||||
* [[Reference for `eif_character_function'|eif_character_function()]]
|
||||
* [[Reference for `eif_disable_visible_exception'|eif_disable_visible_exception()]]
|
||||
* [[Reference for `eif_double_function'|eif_double_function()]]
|
||||
* [[Reference for `eif_enable_visible_exception'|eif_enable_visible_exception()]]
|
||||
* [[Reference for `eif_integer_function'|eif_integer_function()]]
|
||||
* [[Reference for `eif_name'|eif_name()]]
|
||||
* [[Reference for `eif_name_by_tid'|eif_name_by_tid()]]
|
||||
* [[Reference for `eif_pointer_function'|eif_pointer_function()]]
|
||||
* [[Reference for `eif_procedure'|eif_procedure()]]
|
||||
* [[Reference for `eif_protect'|eif_protect()]]
|
||||
* [[Reference for `eif_real_function'|eif_real_function()]]
|
||||
* [[Reference for `eif_reference_function'|eif_reference_function()]]
|
||||
* [[Reference for `eif_string'|eif_string()]]
|
||||
* [[Reference for `eif_type'|eif_type()]]
|
||||
* [[Reference for `eif_type_by_name'|eif_type_by_name()]]
|
||||
* [[Reference for `eif_type_by_reference'|eif_type_by_reference()]]
|
||||
* [[Reference for `eif_type_id'|eif_type_id()]]
|
||||
* [[Reference for `eif_wean'|eif_wean()]]
|
||||
|
||||
|
||||
|
||||
References for CECIL features
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ Note that through CECIL you can use an Eiffel system compiled in any of the Eiff
|
||||
|
||||
{{note|each time you melt the Eiffel system, the ''<system name>. melted'' file is updated. }}
|
||||
|
||||
{{warning| '''Caution''': in the second case (workbench mode), it is not possible to call through the CECIL interface any routine that has been melted in the last compilation; this would raise the run-time exception: <br/>
|
||||
{{caution|In the second case (workbench mode), it is not possible to call through the CECIL interface any routine that has been melted in the last compilation; this would raise the run-time exception: <br/>
|
||||
''' $ applied to melted routine''' <br/>
|
||||
The solution is simply to refreeze the system. }}
|
||||
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
[[Property:title|CECIL]]
|
||||
[[Property:weight|3]]
|
||||
[[Property:uuid|c03112b8-578e-cc1a-ee13-c6928b787529]]
|
||||
* [[CECIL: Introduction|Introduction]]
|
||||
* [[Compiling an Eiffel system for CECIL|Compiling an Eiffel system for CECIL]]
|
||||
* [[Using a CECIL archive|Using a CECIL archive]]
|
||||
* [[CECIL interface overview|CECIL interface overview]]
|
||||
* [[CECIL Reference|CECIL man pages]]
|
||||
* [[CECIL samples|CECIL examples]]
|
||||
This document provides an overview of the C-Eiffel Call-In Library (CECIL) as defined in Eiffel: The Language (ETL). The first section addresses how to compile and run a CECIL program, on the [[Compiling an Eiffel system for CECIL|Eiffel side]] and on the [[Using a CECIL archive|C side]] . The [[CECIL interface overview|second part]] contains a more precise description of the Eiffel types, the protection mechanism as well as how to write and use C externals.
|
||||
|
||||
CECIL, designed by Eiffel Software , is the C library that permits C and C++ applications (as well as applications written in other languages) to take advantage of almost all Eiffel facilities: create Eiffel objects, apply features to them. The basics of CECIL are described in chapter 24 of the reference book on Eiffel, Eiffel: The Language, which covers interfaces between Eiffel and other languages. Important material can also be found in the Eiffel Software manual Eiffel: The Environment.
|
||||
|
||||
The CECIL documentation, man pages and examples are part of the standard delivery of EiffelStudio 5.0 and higher.
|
||||
|
||||
The present document complements the descriptions of Eiffel: The Language. Note that CECIL has been revised and improved since that book was published, so the explanations below have precedence over those in the book.
|
||||
|
||||
This document is intended for both Windows and Unix users. Only a few of the sections, clearly marked, are platform-specific.
|
||||
To access Eiffel mechanisms from C or other external languages:
|
||||
* Compile your Eiffel system so as to generate "Cecilized" code, that is to say code callable from the outside. See [[Compiling an Eiffel system for CECIL|Compiling your Eiffel system for CECIL]] .
|
||||
* In writing the external code that will use the facilities of the Eiffel system, use the CECIL functions as specified in chapter 24 of ''Eiffel: The Language''. See also [[CECIL interface overview|The CECIL interface overview]] .
|
||||
* C-compile and link that code. See [[Using a CECIL archive|Building a C system using CECIL]] .
|
||||
|
||||
For feature by feature specification, please have a look at [[CECIL Reference|the man pages]] .
|
||||
|
||||
|
||||
@@ -2,54 +2,79 @@
|
||||
[[Property:weight|2]]
|
||||
[[Property:uuid|e8438c9b-65ae-368f-6559-a0d5b28db4b7]]
|
||||
==Linking the CECIL archive into a program==
|
||||
The CECIL archive already incorporates the Eiffel run-time. To use the functions provided in the CECIL archive, simply write the C programs according to the CECIL specifications of ETL, and then include the CECIL archive in the link line of your C application. This line looks like:
|
||||
on Unix/linux:
|
||||
The CECIL archive already incorporates the Eiffel run-time. To use the functions provided in the CECIL archive, simply write the C programs according to the CECIL specifications of ETL, and then include the CECIL archive in the link line of your C application.
|
||||
|
||||
|
||||
On Unix/linux, this line looks like this:
|
||||
|
||||
|
||||
<code>ld -o [name of your CECIL executable] [your C object files and archives]lib<system name>.a -lm</code>
|
||||
|
||||
|
||||
{{note|On Unix, linking with "-lm" is required since the Eiffel run-time uses the standard math libraries. You may need to link with other libraries (for example, on linux: with "-lbsd", in MT mode with "-lpthread" (posix threads) or "-lthread" (solaris)). }}
|
||||
|
||||
|
||||
|
||||
on Windows, with MS VC++:
|
||||
|
||||
|
||||
<code>link [your link flags] -OUT:[name of your cecil executable] [your C object files and archives] lib<system name>.lib [other Windows libraries]</code>
|
||||
|
||||
|
||||
|
||||
on Windows with Borland:
|
||||
|
||||
|
||||
<code>ilink32 -ap -c -Tpe main.obj c0w32.obj, [name of your cecil executable],,EIFGENs\target_name\W_code\lib<system name>.lib CW32 IMPORT32 OLE2w32,,</code>
|
||||
|
||||
|
||||
|
||||
'''Notes for compiling CECIL C files:''' <br/>
|
||||
===Notes for compiling CECIL C files:===
|
||||
The CECIL library is built automatically, which is unfortunately not the case of the corresponding object files of the cecil program you wrote. <br/>
|
||||
The C flags to use are usually the same as the ones needed during the compilation of the generated C-code plus those which are relevant to your own C-code.
|
||||
|
||||
Typically, you will compile with your flags as below (if you are using gcc):
|
||||
|
||||
|
||||
<code>gcc -c -O -I$ISE_EIFFEL/studio/spec/$PLATFORM/include -I<SOME_INCLUDE_PATH> -D<SOME_FLAGS> your_file.c</code>
|
||||
|
||||
|
||||
or , if you are on Windows using MS VC++:
|
||||
|
||||
|
||||
<code>cl -c -nologo -Ox -I$ISE_EIFFEL\studio\spec\windows\include -I<SOME_INCLUDE_PATH> -D<SOME_FLAGS> your_file.c</code>
|
||||
|
||||
|
||||
or, if you are on Windows using Borland:
|
||||
|
||||
|
||||
<code>bcc32 -c -I$ISE_EIFFEL\studio\spec\windows\include -I<SOME_INCLUDE_PATH> -D<SOME_FLAGS> your_file.c</code>
|
||||
|
||||
{{sample|if you want to use the multithreaded facilities of Eiffel, you should define the EIFFEL MT flags by adding "-DEIF_THREADS" to the command line and follow the instructions of your C compiler and platform to find out which additional flags you may need '''. For example:''' on Solaris you need to add "-DSOLARIS_THREADS -D_REENTRANT". }}
|
||||
|
||||
{{note|if you want to use the multithreaded facilities of Eiffel, you should define the EIFFEL MT flags by adding "-DEIF_THREADS" to the command line and follow the instructions of your C compiler and platform to find out which additional flags you may need. For example, on Solaris you need to add "-DSOLARIS_THREADS -D_REENTRANT". }}
|
||||
|
||||
|
||||
You can specify a Makefile in your configuration file, so that your C files will be compiled automatically after the Eiffel compilation and before the final linking. See [[Externals Options|the manipulation of external]] in the project settings to add <code>$PATH_TO_MAKEFILE/your_makefile</code>.
|
||||
|
||||
|
||||
This makefile will be run from the $/EIFGENs/target_name/W_code or $/EIFGENs/target_name/F_code directory. You should not give the CECIL executable the same name as your system, because it will be replaced by the Eiffel executable when you run another compilation.
|
||||
|
||||
|
||||
==Initializing the Eiffel run-time==
|
||||
Even though the main thread of control resides in the "C side" of the program, the Eiffel run-time must be initialized correctly before it can use CECIL facilities to communicate with the Eiffel world.
|
||||
In the C file containing the "main" C function, you must add the following line to include the header file "eif_setup. h" provided with this example:
|
||||
|
||||
|
||||
<code>
|
||||
#include "eif_setup.h" /* Macros EIF_INITIALIZE and EIF_DISPOSE_ALL */
|
||||
#include "eif_eiffel.h" /* Exported functions of the Eiffel run-time */</code>
|
||||
|
||||
|
||||
Your "main" function must have the three standard arguments of the C "main" function: "argc", "argv" and "envp" and include the following macros that are defined in "eif_setup. h":
|
||||
|
||||
|
||||
<code>
|
||||
int main(int argc, char **argv, char **envp)
|
||||
/* Please respect this signature: `argc', `argv' and `envp' are used * in EIF_INITIALIZE. */
|
||||
/* Please respect this signature: 'argc', 'argv' and 'envp' are used * in EIF_INITIALIZE. */
|
||||
{
|
||||
/* declarations of variables */
|
||||
/* Initialize the Eiffel run-time. */
|
||||
@@ -61,10 +86,11 @@ int main(int argc, char **argv, char **envp)
|
||||
EIF_DISPOSE_ALL
|
||||
}</code>
|
||||
|
||||
{{note|s''': <br/>
|
||||
The above mentioned macros must imperatively be in the body of the "main" function for the Eiffel exception handling mechanism to work correctly. You also need to add the Eiffel run time directory to the list of directories in which the C compiler searches for include files. You can do so by using the "-I" option of your C compiler. You can only link one CECIL library into your C applications at a time. }}
|
||||
|
||||
{{warning| '''Caution''': Even though external object files and archives are correctly specified in the "object" clause of the configuration file, you will need to explicitly link them to your C application. }}
|
||||
{{note|The above mentioned macros must imperatively be in the body of the "main" function for the Eiffel exception handling mechanism to work correctly. You also need to add the Eiffel run time directory to the list of directories in which the C compiler searches for include files. You can do so by using the "-I" option of your C compiler. You can only link one CECIL library into your C applications at a time. }}
|
||||
|
||||
|
||||
{{caution|Even though external object files and archives are correctly specified in the "object" clause of the configuration file, you will need to explicitly link them to your C application. }}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user