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.
Return compiler options given via the environment variable
Is the same as
Compiles the code in the file
Returns
This option is a fast way to test whether a module will
compile successfully. This is useful for code generators
that want to verify the code that they emit. No code is
generated. If warnings are enabled, warnings generated by
the
Use option
Similar to option
The compiler returns 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).
For more information, see the section about
Allows compilers built on top of
It is advised for compilers to remove all non-deterministic
information if the
The compiler will compress the generated object code, which can be useful for embedded systems.
Includes debug information in the form of
Warning: Source code can be reconstructed from
the debug information. Use encrypted debug information
(
For details, see
Includes custom debug information in the form of a
Warning: Source code can be reconstructed from
the debug information. Use encrypted debug information
(
Includes debug information, but encrypts it so that it
cannot be accessed without supplying the key. (To give
option
For details, see
Similar to the
For details, see
Omit the
Produces a Makefile rule to track headers dependencies. No object file is produced.
By default, this rule is written to
For example, if you have the following module:
-module(module).
-include_lib("eunit/include/eunit.hrl").
-include("header.hrl").
The Makefile rule generated by this option looks as follows:
module.beam: module.erl \
/usr/local/lib/erlang/lib/eunit/include/eunit.hrl \
header.hrl
The dependecies are created as a side effect to the
normal compilation process. This means that the object
file will also be produced. This option override the
Writes generated rules to
Changes the name of the rule emitted to
Characters in
Considers missing headers as generated files and adds them to the dependencies.
Adds 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.
A short form for both
If this flag is set,
If this flag is set, an extra field, containing
Causes warnings to be treated as errors. This option is supported since R13B04.
A short form for both
Causes more verbose information from the compiler, describing what it is doing.
Overrides the source file name as presented in
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.
Adds
The base name of the compiled file
The directories specified using option
Defines a macro
Causes the parse transformation function
The input file is expected to be assembler code (default file suffix ".S"). Notice that the format of assembler files is not documented, and can change between releases.
The input file is expected to be core code (default file suffix ".core"). Notice that the format of core files is not documented, and can change between releases.
By default, all code is compiled in a separate process which is terminated at the end of compilation. However, some tools, like Dialyzer or compilers for other BEAM languages, may already manage their own worker processes and spawning an extra process may slow the compilation down. In such scenarios, you can pass this option to stop the compiler from spawning an additional process.
This option is not recommended.
By default, the generated code for
operation
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
As from R14A and forward, the compiler resolves calls
without module prefix to local or imported functions before
trying with 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
Omits line number information to produce a slightly smaller output file.
Pass extra chunks to be stored in the
If warnings are turned on (option
In the descriptions that follow, the form that is used to change the default value are listed.
Causes warnings to be emitted for malformed format
strings as arguments to
The default verbosity is
This option is removed, it generates a fatal error if used.
As from 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 discouraged. As from R14A, it is an error to use it.
To resolve BIF clashes, use explicit module names or the
This option is removed, it generates a fatal error if used.
The use of this option has always been discouraged. As from R14A, it is an error to use it.
To resolve BIF clashes, use explicit module names or the
Turns off warnings for uses of the
Emits warnings for all implicitly exported variables referred to after the primitives where they were first defined. By default, the compiler only emits warnings for exported variables referred to in a pattern.
Turns off warnings for "fresh" variables in functional objects or list comprehensions with the same name as some already defined variable. Default is to emit warnings for such variables.
Turns off warnings for unused local functions. Default is to emit warnings for all local functions that are not called directly or indirectly by an exported function. The compiler does not include unused local functions in the generated beam file, but the warning is still useful to keep the source code cleaner.
Turns off warnings for unused local functions like
Turns off warnings for calls to deprecated functions. Default
is to emit warnings for every call to a function known by the
compiler to be deprecated. Notice that the compiler does not know
about attribute
Turns off warnings for calls to deprecated functions like
Turns off warnings for use of deprecated types. Default is to emit warnings for every use of a type known by the compiler to be deprecated.
Turns off warnings for calls to old type testing BIFs,
such as
Emits warnings for unused imported functions. Default is to emit no warnings for unused imported functions.
By default, warnings are emitted for unused variables, except for 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. Default is to emit warnings for unused locally defined record types.
Another class of warnings is generated by the compiler
during optimization and code generation. They warn about
patterns that will never match (such as
Those warnings cannot be disabled (except by disabling all warnings).
The compiler does not warn for expressions that it
does not attempt to optimize. For example, the compiler tries
to evaluate
The absence of warnings does not mean that there are no remaining errors in the code.
All options, except the include path
(
Before OTP 22, the option
For debugging of the compiler, or for pure curiosity,
the intermediate code generated by each compiler pass can be
inspected.
To print a complete list of the options to produce list files,
type
Unrecognized options are ignored.
Both
[{FileName,[ErrorInfo]}].
Is the same as
Analogous to
Uses an
Determines whether the compiler generates a
Works like
Works like
Works like
The (host operating system) environment variable
The list is appended to any options given to
The list can be retrieved with
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 are reported as
occurring in the function the body was inlined into. Also,
When a function is inlined, the original function is
kept if it is exported (either by an explicit export or if the
option
Inlining does not necessarily improve running time. For example, inlining can increase Beam stack use, which probably is 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 option
Example of explicit inlining:
-compile({inline,[pi/0]}). pi() -> 3.1416.
Example of implicit inlining:
-compile(inline).
The option
Example:
%% Aggressive inlining - will increase code size. -compile(inline). -compile({inline_size,100}).
The compiler can also inline various list manipulation functions
from the module
This feature must be explicitly enabled with a compiler option or a
To enable inlining of list functions, use option
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)