Difference between revisions of "Compile to c"
(→Compilation mode: more on debug) |
m (13 revisions: initial import from SamrtEiffel Wiki - The Grand SmartEiffel Book) |
||
(One intermediate revision by the same user not shown) | |||
Line 180: | Line 180: | ||
== <div id="Generation">Generation</div> == |
== <div id="Generation">Generation</div> == |
||
− | ''(to be completed...)'' |
+ | ''(to be completed...)''. See [[C code generation]] |
Revision as of 22:04, 3 March 2013
The compile_to_c command is the ANSI C code generator. This command is usually called automatically from compile, but you can also use it on its own to produce the C code. Like compile, there are two ways of running it: traditional mode and ACE mode.
- In traditional mode, many options can be given on the command line.
- In ACE (Assembly of Classes in Eiffel) mode, most of its options are not allowed on the command line; but they have equivalents in the ACE file.
Synopsis
se c2c [options] <root_class> [<root_procedure>]
se c2c [common_options] <ace_file.ace>
The first usage is traditional mode; the second is ACE mode.
In ACE mode, the name of the ACE file must end with the suffix .ace.
The compile_to_c command produces the C files (*.h and *.c). A script file is also created, whose name depends on the application. This is a .make file (under UNIX) or a .BAT file (under DOS).
The compile_to_c command must have at least one argument which specifies the program's starting point; this is in fact a class's creation procedure. In ACE mode this data is obtained from parameters in the ACE file. In traditional mode, at least the class name must be specified; the default name of the creation class is make, which has to exist; otherwise, the creation method must be specified.
In all cases, the creation method must be one without arguments.
Loading Eiffel files
The compile_to_c command uses the same process as finder to find and load the Eiffel files to compile. Note that, as with finder, the process differs according to whether you are using traditional or ACE mode.
Common options
These options can be used both in ACE mode and in traditional mode.
-help
|
Display a short summary of the command line syntax, with a complete list of the compiler options. |
-verbose
|
Display (an enormous amount of) information during compilation: a complete trace of files loaded, type inference scores, generated files and so on. |
-version
|
Display the SmartEiffel version number. |
Options specific to traditional mode
Compilation mode
There are eight compilation modes which give the eight levels of assertion checking. In ascending order of verification they are:
- boost is a mode in which no validity checking is done and in which SmartEiffel does additional processing compared to the other modes. In particular, in this mode:
- the execution stack is not managed by SmartEiffel,
- the behavior of certain language constructs is changed:
- no tests for Void (which leads to a segfault if there is any problem...)
- no tests for type conformity (ditto; cf the forced assignment operator ::=)
- if else is missing from an inspect clause, the last branch is used for else,
- and and or become semi-strict (i.e. the second expression may not be evaluated if the first expression is enough to infer the result of the and or or expression, like and than and or else)
- SmartEiffel does an optimization pass; in particular, certain functions are put in line;
- no_check is a mode in which no validity checking is done, but the above optimizations are not done (in particular, the execution stack is always managed, the Void tests and type checks are always done, and so on);
- require_check is a mode in which only the preconditions are checked;
- ensure_check is a mode in which the preconditions and postconditions are checked;
- invariant_check is a mode in which the preconditions, postconditions and class invariants are checked;
- loop_check is a mode in which the preconditions, postconditions and class invariants are checked and loop variants and invariants are checked as well;
- all_check is a mode in which all assertions (those above and the check clauses) are checked;
- debug_check is a mode in which all assertions are checked and the debug clauses are compiled too.
-boost
|
Activate boost mode. |
-no_check
|
Activate no_check mode. |
-require_check
|
Activate require_check mode. |
-ensure_check
|
Activate ensure_check mode. |
-invariant_check
|
Activate invariant_check mode. |
-loop_check
|
Activate loop_check mode. |
-all_check
|
Activate all_check mode. |
-debug_check
|
Activate debug_check mode. This level will disappear in 2.3. It is replaced by a -debug flag independent from the assertion level (see below). |
-debug
|
New in 2.3: Compile debug blocks. This flag may be used with any other assertion level flag. The old -debug_check is deprecated and can be replaced by -all_check -debug .
|
Warnings
These options affect the compilation process, but do not change the generated C code.
-no_style_warning
|
Suppress the display of warning messages about non-compliance with Eiffel style rules (this flag does not have any effect any more in 2.3). |
-no_warning
|
Suppress all warning messages. This implies -no_style_warning. |
Advanced options
Not affecting the generated C code
These options affect the compilation process, but do not change the generated C code.
-o <executable>
|
Specify the name of the executable program. |
-loadpath <loadpath_file>
|
Add a file containing Eiffel class search paths. For details see the finder command. |
-no_strip
|
Do not strip symbol data from the executable file. This option is useful for debugging the C code (either generated or included code). |
-high_memory_compiler
|
Allow the compiler to use more memory... This can allow faster compilation, if you have enough RAM. |
-relax
|
????? |
Affecting the generated C code
These options change the generated C code.
-c_mode <C_mode>
|
Use a different C mode. |
-cc <C_compiler>
|
Call the specified C compiler instead of the one in the default configuration. This option is incompatible with <-c_mode> and should generally be avoided except under very special circumstances. |
-no_split
|
Produce a single C file containing the entire application. This can allow the C compiler to do a lot of optimisation and is therefore useful for the production stage of a project. This option is usually implied if you use -c_mode release. |
-no_gc
|
No garbage collector.
When this option is used, the garbage collector is not produced and (at least) one malloc() is done for each object creation. This option is useful if you want to use another garbage collector from an external library, like the Boehm-Demers-Weiser one, for example, or when a garbage collector is not needed. Without this option, SmartEiffel builds a garbage collector tailored to the application. |
-gc_info
|
When this option is used, the garbage collector displays at run time some information about its use. |
-cecil <cecil_file>
|
Allow Eiffel features to be called from C (see cecil for details). |
-no_main
|
Do not generate a main() C function. In this case the root creation method is not called. This can be useful when you want to start execution from outside before calling Eiffel routines via the cecil interface.
Before calling the first Eiffel routine, do not forget to call the routine initialize_eiffel_runtime(argc, argv); which initialises the Eiffel system. |
-sedb
|
This option allows you to include the SmartEiffel debugger in your executable. |
-profile
|
This option allows you to include the profiler in your executable. |
-manifest_string_trace
|
This option allows you to include in your executable a trace of the creation of manifest strings. This can be useful for tracking down some memory errors. |
Options passed to the C compiler
All unrecognised options are passed to the C compiler.
Generation
(to be completed...). See C code generation