This module provides an interface to the standard Erlang compiler. It can generate either a new file which contains the object code, or return a binary which can be loaded directly.
Is the same as
Compiles the code in the file
Returns
This option is fast way to test whether a module will
compile successfully (mainly useful for code generators
that want to verify the code they emit). No code will
generated. If warnings are enabled, warnings generated by
the
Use the
Similar to the
Causes the compiler to return the object code in a
binary instead of creating an object file. If successful,
the compiler returns
The compiler will emit informational warnings about binary matching optimizations (both successful and unsuccessful). See the Efficiency Guide for further information.
The compiler will compress the generated object code, which can be useful for embedded systems.
Include debug information in the form of abstract code
(see
Warning: Source code can be reconstructed from the debug information. Use encrypted debug information (see below) to prevent this.
See
Include debug information, but encrypt it, so that it
cannot be accessed without supplying the key. (To give
the
See
Like the
See
Produce a Makefile rule to track headers dependencies. No object file is produced.
By default, this rule is written to
For instance, if one has the following module:
-module(module).
-include_lib("eunit/include/eunit.hrl").
-include("header.hrl").
Here is the Makefile rule generated by this option:
module.beam: module.erl \
/usr/local/lib/erlang/lib/eunit/include/eunit.hrl \
header.hrl
Write generated rule(s) to
Change the name of the rule emitted to
Characters in
Consider missing headers as generated files and add them to the dependencies.
Add a phony target for each dependency.
Produces a listing of the parsed code after preprocessing
and parse transforms, in the file
Produces a listing of the code after all source code
transformations have been performed, in the file
Produces a listing of the assembler code in the file
Causes errors/warnings to be printed as they occur.
This is a short form for both
If this flag is set, then
If this flag is set, then an extra field containing
Causes warnings to be treated as errors. This option is supported since R13B04.
This is a short form for both
Causes more verbose information from the compiler describing what it is doing.
Sets the value of the source, as returned by
Sets a new directory for the object code. The current directory is used for output, except when a directory has been specified with this option.
Causes all functions in the module to be exported.
Add
the base name of the compiled file;
the directories specified using the
Defines a macro
Causes the parse transformation function
The input file is expected to be assembler code (default file suffix ".S"). Note that the format of assembler files is not documented, and may change between releases.
The input file is expected to be core code (default file suffix ".core"). Note that the format of core files is not documented, and may change between releases.
This option is not recommended.
By default, the generated code for
the
Normally the compiler verifies that the module name given in the source code is the same as the base name of the output file and refuses to generate an output file if there is a mismatch. If you have a good reason (or other reason) for having a module name unrelated to the name of the output file, this option disables that verification (there will not even be a warning if there is a mismatch).
Makes the function
From R14A and forward, the compiler resolves calls
without module prefix to local or imported functions before
trying auto-imported BIFs. If the BIF is to be
called, use the
If this option is written in the source code, as a
-compile({no_auto_import,[error/1]}).
Do not auto import any functions from the module
Omit line number information in order to produce a slightly smaller output file.
If warnings are turned on (the
Causes warnings to be emitted for malformed format
strings as arguments to
This option is removed, it will generate a fatal error if used.
Beginning with R14A, the compiler no longer calls the
auto-imported BIF if the name clashes with a local or
explicitly imported function and a call without explicit
module name is issued. Instead the local or imported
function is called. Still accepting
The use of this option has always been strongly discouraged. From OTP R14A and forward it's an error to use it.
To resolve BIF clashes, use explicit module names or the
This option is removed, it will generate a fatal error if used.
The use of this option has always been strongly discouraged. From OTP R14A and forward it's an error to use it.
To resolve BIF clashes, use explicit module names or the
Causes a warning to be emitted if the
Causes warnings to be emitted for all implicitly
exported variables referred to after the primitives
where they were first defined. No warnings for exported
variables unless they are referred to in some pattern,
which is the default, can be selected by the option
Causes warnings to be emitted for "fresh" variables
in functional objects or list comprehensions with the same
name as some already defined variable. The default is to
warn for such variables. No warnings for shadowed
variables can be selected by the option
Turns off warnings for unused local functions.
By default (
Turns off warnings for unused local functions as
Turns off warnings for calls to deprecated functions. By
default (
Turns off warnings for calls to deprecated functions as
Turns off warnings for uses of deprecated types. By
default (
Causes warnings to be emitted for calls to old type
testing BIFs such as
Causes warnings to be emitted for unused imported
functions. No warnings for unused imported functions,
which is the default, can be selected by the option
By default, warnings are emitted for variables which are not used, with the exception of variables beginning with an underscore ("Prolog style warnings"). Use this option to turn off this kind of warnings.
Turns off warnings for unused record types. By
default (
Another class of warnings is generated by the compiler
during optimization and code generation. They warn about
patterns that will never match (such as
Note that the compiler does not warn for expressions that it
does not attempt to optimize. For instance, the compiler tries
to evaluate
Currently, those warnings cannot be disabled (except by disabling all warnings).
Obviously, the absence of warnings does not mean that there are no remaining errors in the code.
Note that all the options except the include path
(
Note also that the
For debugging of the compiler, or for pure curiosity,
the intermediate code generated by each compiler pass can be
inspected.
A complete list of the options to produce list files can be
printed by typing
Unrecognized options are ignored.
Both
[{FileName,[ErrorInfo]}].
Is the same as
Analogous to
Uses an
Determines whether the compiler would generate a
Works exactly like
Works exactly like
Works exactly like
The (host operating system) environment variable
The list will be appended to any options given to
The compiler can do function inlining within an Erlang
module. Inlining means that a call to a function is replaced with
the function body with the arguments replaced with the actual
values. The semantics are preserved, except if exceptions are
generated in the inlined code. Exceptions will be reported as
occurring in the function the body was inlined into. Also,
When a function is inlined, the original function will be
kept if it is exported (either by an explicit export or if the
Inlining does not necessarily improve running time. For instance, inlining may increase Beam stack usage which will probably be detrimental to performance for recursive functions.
Inlining is never default; it must be explicitly enabled with a
compiler option or a
To enable inlining, either use the
Example of explicit inlining:
-compile({inline,[pi/0]}). pi() -> 3.1416.
Example of implicit inlining:
-compile(inline).
The
Example:
%% Aggressive inlining - will increase code size. -compile(inline). -compile({inline_size,100}).
The compiler can also inline a variety of list manipulation functions from the stdlib's lists module.
This feature must be explicitly enabled with a compiler option or a
To enable inlining of list functions, use the
The following functions are inlined:
Parse transformations are used when a programmer wants to use Erlang syntax but with different semantics. The original Erlang code is then transformed into other Erlang code.
The
{ErrorLine, Module, ErrorDescriptor}
A string describing the error is obtained with the following call:
Module:format_error(ErrorDescriptor)