- 17.05 (released) ...
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.
On Unix/linux, this line looks like this:
ld -o [name of your CECIL executable] [your C object files and archives]lib<system name>.a -lm
on Windows, with MS VC++:
link [your link flags] -OUT:[name of your cecil executable] [your C object files and archives] lib<system name>.lib [other Windows libraries]
on Windows with Borland:
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,,
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.
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):
gcc -c -O -I$ISE_EIFFEL/studio/spec/$PLATFORM/include -I<SOME_INCLUDE_PATH> -D<SOME_FLAGS> your_file.c
or , if you are on Windows using MS VC++:
cl -c -nologo -Ox -I$ISE_EIFFEL\studio\spec\windows\include -I<SOME_INCLUDE_PATH> -D<SOME_FLAGS> your_file.c
or, if you are on Windows using Borland:
bcc32 -c -I$ISE_EIFFEL\studio\spec\windows\include -I<SOME_INCLUDE_PATH> -D<SOME_FLAGS> your_file.c
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 the manipulation of external in the project settings to add
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:
#include "eif_setup.h" /* Macros EIF_INITIALIZE and EIF_DISPOSE_ALL */
#include "eif_eiffel.h" /* Exported functions of the Eiffel run-time */
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":
int main(int argc, char **argv, char **envp)
/* Please respect this signature: 'argc', 'argv' and 'envp' are used * in EIF_INITIALIZE. */
/* declarations of variables */
/* Initialize the Eiffel run-time. */
/* body of your "main" function */
/* Reclaim the memory allocated by the Eiffel run-time. */
- Parent <CECIL>