Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > eb1ec8bb814fe4d749258d46ae8ea988 > files > 260

erlang-doc-18.3.2-9.1.mga6.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css">
<title>Erlang -- compile</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/compiler-6.0.3.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Compiler</strong><br><strong>Reference Manual</strong><br><small>Version 6.0.3</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p>
<ul class="flipMenu"><li id="loadscrollpos" title="compile " expanded="true">compile<ul>
<li><a href="compile.html">
                  Top of manual page
                </a></li>
<li title="file-1"><a href="compile.html#file-1">file/1</a></li>
<li title="file-2"><a href="compile.html#file-2">file/2</a></li>
<li title="forms-1"><a href="compile.html#forms-1">forms/1</a></li>
<li title="forms-2"><a href="compile.html#forms-2">forms/2</a></li>
<li title="format_error-1"><a href="compile.html#format_error-1">format_error/1</a></li>
<li title="output_generated-1"><a href="compile.html#output_generated-1">output_generated/1</a></li>
<li title="noenv_file-2"><a href="compile.html#noenv_file-2">noenv_file/2</a></li>
<li title="noenv_forms-2"><a href="compile.html#noenv_forms-2">noenv_forms/2</a></li>
<li title="noenv_output_generated-1"><a href="compile.html#noenv_output_generated-1">noenv_output_generated/1</a></li>
</ul>
</li></ul>
</div></div>
<div id="content">
<div class="innertube">
<!-- refpage --><center><h1>compile</h1></center>
  
  <h3>MODULE</h3>
<div class="REFBODY">compile</div>
  <h3>MODULE SUMMARY</h3>
<div class="REFBODY">Erlang Compiler</div>
  <h3>DESCRIPTION</h3>
<div class="REFBODY"><p>
    <p>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.
    </p>
  </p></div>

  <h3>EXPORTS</h3>
    <p><a name="file-1"><span class="bold_code">file(File)</span></a><br></p>
<div class="REFBODY"><p>
        <p>Is the same as
	  <span class="code">file(File, [verbose,report_errors,report_warnings])</span>.
	</p>
      </p></div>

    <p><a name="file-2"><span class="bold_code">file(File, Options) -&gt; CompRet</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">CompRet = ModRet | BinRet | ErrRet</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">ModRet = {ok,ModuleName} | {ok,ModuleName,Warnings}</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">BinRet = {ok,ModuleName,Binary} | {ok,ModuleName,Binary,Warnings}</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">ErrRet = error | {error,Errors,Warnings}</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Compiles the code in the file <span class="code">File</span>, which is an
	  Erlang source code file without the <span class="code">.erl</span> extension.
	  <span class="code">Options</span> determine the behavior of the compiler.</p>

        <p>Returns <span class="code">{ok,ModuleName}</span> if successful, or <span class="code">error</span>
	  if there are errors. An object code file is created if
	  the compilation succeeds without errors. It is considered
	  to be an error if the module name in the source code is
	  not the same as the basename of the output file.</p>

        <p><a name="type-option"></a>Available options:</p>
        <dl>
          <dt><strong><span class="code">basic_validation</span></strong></dt>
          <dd>
            <p>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 <span class="code">erl_lint</span> module (such as warnings for unused
	      variables and functions) are also returned.</p>

            <p>Use option <span class="code">strong_validation</span> to generate all
	      warnings that the compiler would generate.</p>
          </dd>

          <dt><strong><span class="code">strong_validation</span></strong></dt>
          <dd>
            <p>Similar to option <span class="code">basic_validation</span>. No code
	      is generated, but more compiler passes are run
	      to ensure that warnings generated by the optimization
	      passes are generated (such as clauses that will not match,
	      or expressions that are guaranteed to fail with an
	      exception at runtime).</p>
          </dd>

          <dt><strong><span class="code">binary</span></strong></dt>
          <dd>
            <p>The compiler returns the object code in a
              binary instead of creating an object file. If successful,
              the compiler returns <span class="code">{ok,ModuleName,Binary}</span>.</p>
          </dd>

          <dt><strong><span class="code">bin_opt_info</span></strong></dt>
          <dd>
            <p>The compiler will emit informational warnings about binary
	    matching optimizations (both successful and unsuccessful).
	    For more information, see the section about
	    <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','doc/efficiency_guide','binaryhandling.html#bin_opt_info');">bin_opt_info</a></span>
	    in the Efficiency Guide.</p>
          </dd>

          <dt><strong><span class="code">compressed</span></strong></dt>
          <dd>
            <p>The compiler will compress the generated object code,
	    which can be useful for embedded systems.</p>
          </dd>

          <dt><strong><span class="code">debug_info</span></strong></dt>
          <dd>
            <a name="debug_info"></a>
            <p>Includes debug information in the form of abstract code
              (see
              <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','erts','absform.html');">The Abstract Format</a></span>
              in ERTS User's Guide) in the compiled beam module. Tools
	      such as <span class="code">Debugger</span>, <span class="code">Xref</span>, and <span class="code">Cover</span> require 
	      the debug information to be included.</p>

            <p><strong>Warning</strong>: Source code can be reconstructed from
              the debug information. Use encrypted debug information
              (<span class="code">encrypt_debug_info</span>) to prevent this.</p>

            <p>For details, see
              <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','beam_lib.html#debug_info');">beam_lib(3)</a></span>.</p>
          </dd>

          <dt><strong><span class="code">{debug_info_key,KeyString}</span></strong></dt>
          <dd></dd>
          <dt><strong><span class="code">{debug_info_key,{Mode,KeyString}}</span></strong></dt>
          <dd>
            <a name="debug_info_key"></a>
            <p>Includes debug information, but encrypts it so that it
              cannot be accessed without supplying the key. (To give
              option <span class="code">debug_info</span> as well is allowed, but
              not necessary.) Using this option is a good way to always
              have the debug information available during testing, yet
              protecting the source code.</p>
            <p><span class="code">Mode</span> is the type of crypto algorithm to be used
              for encrypting the debug information. The default
              (and currently the only) type is <span class="code">des3_cbc</span>.</p>
            <p>For details, see
              <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','beam_lib.html#debug_info');">beam_lib(3)</a></span>.</p>
          </dd>

          <dt><strong><span class="code">encrypt_debug_info</span></strong></dt>
          <dd>
            <a name="encrypt_debug_info"></a>
            <p>Similar to the <span class="code">debug_info_key</span> option, but
	      the key is read from an <span class="code">.erlang.crypt</span> file.
	    </p>

	    <p>For details, see
              <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','beam_lib.html#debug_info');">beam_lib(3)</a></span>.</p>
          </dd>

          <dt><strong><span class="code">makedep</span></strong></dt>
          <dd>
            <p>Produces a Makefile rule to track headers dependencies.
              No object file is produced.
            </p>
            <p>By default, this rule is written to
              <span class="code">&lt;File&gt;.Pbeam</span>. However, if option
                <span class="code">binary</span> is set, nothing is written and the rule is
                returned in <span class="code">Binary</span>.
            </p>
            <p>For example, if you have the following module:
            </p>
            <div class="example"><pre>
-module(module).

-include_lib("eunit/include/eunit.hrl").
-include("header.hrl").</pre></div>
            <p>The Makefile rule generated by this option looks as follows:
            </p>
            <div class="example"><pre>
module.beam: module.erl \
  /usr/local/lib/erlang/lib/eunit/include/eunit.hrl \
  header.hrl</pre></div>
          </dd>

          <dt><strong><span class="code">{makedep_output, Output}</span></strong></dt>
          <dd>
            <p>Writes generated rules to <span class="code">Output</span> instead of the
              default <span class="code">&lt;File&gt;.Pbeam</span>. <span class="code">Output</span>
              can be a filename or an <span class="code">io_device()</span>. To write to
              stdout, use <span class="code">standard_io</span>. However, if <span class="code">binary</span>
              is set, nothing is written to <span class="code">Output</span> and the
              result is returned to the caller with
              <span class="code">{ok, ModuleName, Binary}</span>.
            </p>
          </dd>

          <dt><strong><span class="code">{makedep_target, Target}</span></strong></dt>
          <dd>
            <p>Changes the name of the rule emitted to <span class="code">Target</span>.
            </p>
          </dd>

          <dt><strong><span class="code">makedep_quote_target</span></strong></dt>
          <dd>
            <p>Characters in <span class="code">Target</span> special to make(1) are quoted.
            </p>
          </dd>

          <dt><strong><span class="code">makedep_add_missing</span></strong></dt>
          <dd>
            <p>Considers missing headers as generated files and adds them to the
              dependencies.
            </p>
          </dd>

          <dt><strong><span class="code">makedep_phony</span></strong></dt>
          <dd>
            <p>Adds a phony target for each dependency.
            </p>
          </dd>

          <dt><strong><span class="code">'P'</span></strong></dt>
          <dd>
            <p>Produces a listing of the parsed code, after preprocessing
	      and parse transforms, in the file
	      <span class="code">&lt;File&gt;.P</span>. No object file is produced.
	    </p>
          </dd>

          <dt><strong><span class="code">'E'</span></strong></dt>
          <dd>
            <p>Produces a listing of the code, after all source code
	      transformations have been performed, in the file
	      <span class="code">&lt;File&gt;.E</span>. No object file is produced.
	    </p>
          </dd>

          <dt><strong><span class="code">'S'</span></strong></dt>
          <dd>
            <p>Produces a listing of the assembler code in the file
              <span class="code">&lt;File&gt;.S</span>. No object file is produced.
	    </p>
          </dd>

          <dt><strong><span class="code">report_errors/report_warnings</span></strong></dt>
          <dd>
            <p>Causes errors/warnings to be printed as they occur.</p>
          </dd>

          <dt><strong><span class="code">report</span></strong></dt>
          <dd>
            <p>A short form for both <span class="code">report_errors</span> and
              <span class="code">report_warnings</span>.</p>
          </dd>

          <dt><strong><span class="code">return_errors</span></strong></dt>
          <dd>
            <p>If this flag is set,
	      <span class="code">{error,ErrorList,WarningList}</span> is returned when
	      there are errors.</p>
          </dd>

          <dt><strong><span class="code">return_warnings</span></strong></dt>
          <dd>
            <p>If this flag is set, an extra field, containing
              <span class="code">WarningList</span>, is added to the tuples returned on
              success.</p>
          </dd>

          <dt><strong><span class="code">warnings_as_errors</span></strong></dt>
          <dd>
            <p>Causes warnings to be treated as errors. This option is supported
            since R13B04.</p>
          </dd>

          <dt><strong><span class="code">return</span></strong></dt>
          <dd>
            <p>A short form for both <span class="code">return_errors</span> and
              <span class="code">return_warnings</span>.</p>
          </dd>

	  <dt><strong><span class="code">verbose</span></strong></dt>
          <dd>
            <p>Causes more verbose information from the compiler,
              describing what it is doing.</p>
          </dd>

	  <dt><strong><span class="code">{source,FileName}</span></strong></dt>
          <dd>
            <p>Sets the value of the source, as returned by
              <span class="code">module_info(compile)</span>.</p>
          </dd>

	  <dt><strong><span class="code">{outdir,Dir}</span></strong></dt>
          <dd>
            <p>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.</p>
          </dd>

	  <dt><strong><span class="code">export_all</span></strong></dt>
          <dd>
            <p>Causes all functions in the module to be exported.</p>
          </dd>

	  <dt><strong><span class="code">{i,Dir}</span></strong></dt>
          <dd>
            <p>Adds <span class="code">Dir</span> to the list of directories to be searched
              when including a file. When encountering an
	      <span class="code">-include</span> or <span class="code">-include_lib</span> directive,
	      the compiler searches for header files in the following
	      directories:</p>
            <ul>
              <li>
                <p><span class="code">"."</span>, the current working directory of
		  the file server</p>
              </li>
              <li>
                <p>The base name of the compiled file</p>
              </li>
              <li>
                <p>The directories specified using option <span class="code">i</span>;
                  the directory specified last is searched first</p>
              </li>
            </ul>
          </dd>

          <dt><strong><span class="code">{d,Macro}</span></strong></dt>
          <dd></dd>
          <dt><strong><span class="code">{d,Macro,Value}</span></strong></dt>
          <dd>
            <p>Defines a macro <span class="code">Macro</span> to have the value
            <span class="code">Value</span>. <span class="code">Macro</span> is of type atom, and <span class="code">Value</span> can be any term.
            The default <span class="code">Value</span> is <span class="code">true</span>.</p>
          </dd>

	  <dt><strong><span class="code">{parse_transform,Module}</span></strong></dt>
          <dd>
            <p>Causes the parse transformation function
              <span class="code">Module:parse_transform/2</span> to be applied to the
              parsed code before the code is checked for errors.</p>
          </dd>

	  <dt><strong><span class="code">from_asm</span></strong></dt>
          <dd>
            <p>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.</p>
          </dd>

	  <dt><strong><span class="code">from_core</span></strong></dt>
          <dd>
            <p>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.</p>
          </dd>

          <dt><strong><span class="code">no_strict_record_tests</span></strong></dt>
          <dd>
            <p>This option is not recommended.</p>

	    <p>By default, the generated code for
	      operation <span class="code">Record#record_tag.field</span> verifies that
	      the tuple <span class="code">Record</span> has the correct size for
	      the record, and that the first element is the tag
	      <span class="code">record_tag</span>. Use this option to omit
	      the verification code.</p>
          </dd>

          <dt><strong><span class="code">no_error_module_mismatch</span></strong></dt>
          <dd>
            <p>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).</p>
          </dd>

          <dt><strong><span class="code">{no_auto_import,[{F,A}, ...]}</span></strong></dt>
          <dd>
	  <p>Makes the function <span class="code">F/A</span> no longer being
          auto-imported from the <span class="code">erlang</span> module, which resolves
          BIF name clashes. This option must be used to resolve name
          clashes with BIFs auto-imported before R14A, if it is needed to
          call the local function with the same name as an
          auto-imported BIF without module prefix.</p>
	  <div class="note">
<div class="label">Note</div>
<div class="content"><p>
	  <p>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 <span class="code">erlang</span> module prefix in the call, not
	  <span class="code">{ no_auto_import,[{F,A}, ...]}</span>.</p>
	  </p></div>
</div>
	  <p>If this option is written in the source code, as a 
	  <span class="code">-compile</span> directive, the syntax <span class="code">F/A</span> can be used instead 
	  of <span class="code">{F,A}</span>, for example:</p>
	  <div class="example"><pre>-compile({no_auto_import,[error/1]}).</pre></div>
	  </dd>

          <dt><strong><span class="code">no_auto_import</span></strong></dt>
          <dd>
            <p>Do not auto-import any functions from <span class="code">erlang</span> module.</p>
          </dd>

          <dt><strong><span class="code">no_line_info</span></strong></dt>

          <dd>
            <p>Omits line number information to produce a slightly
	      smaller output file.
	    </p>
          </dd>

        </dl>

        <p>If warnings are turned on (option <span class="code">report_warnings</span>
          described earlier), the following options control what type of
          warnings that are generated.
	  <a name="erl_lint_options"></a>
          Except from <span class="code">{warn_format,Verbosity}</span>, the following options 
	have two forms:</p>
	  <ul>
	    <li>A <span class="code">warn_xxx</span> form, to turn on the warning.</li>
	    <li>A <span class="code">nowarn_xxx</span> form, to turn off the warning.</li>
	  </ul>
	  <p>In the descriptions that follow, the form that is used to change 
	  the default value are listed.</p>

        <dl>
          <dt><strong><span class="code">{warn_format, Verbosity}</span></strong></dt>
          <dd>
            <p>Causes warnings to be emitted for malformed format
              strings as arguments to <span class="code">io:format</span> and similar
              functions.</p>
	      <p><span class="code">Verbosity</span> selects the number of warnings:</p>
	      <ul>
		<li>
<span class="code">0</span> = No warnings</li>
		<li>
<span class="code">1</span> = Warnings for invalid format strings and incorrect 
		number of arguments</li>
		<li>
<span class="code">2</span> = Warnings also when the validity cannot 
		be checked, for example, when the format string argument is a
		variable.</li>
	      </ul>
	      <p>The default verbosity is <span class="code">1</span>. Verbosity <span class="code">0</span> can
              also be selected by option <span class="code">nowarn_format</span>.</p>
          </dd>

          <dt><strong><span class="code">nowarn_bif_clash</span></strong></dt>
          <dd>
            <p>This option is removed, it generates a fatal error if used.</p>

	    <div class="warning">
<div class="label">Warning</div>
<div class="content"><p>
	    <p>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 <span class="code">nowarn_bif_clash</span> would 
	    make a module calling functions clashing with auto-imported BIFs
	    compile with both the old and new compilers, but with
	    completely different semantics. This is why the option is removed.</p>

	    <p>The use of this option has always been discouraged.
	    As from R14A, it is an error to use it.</p>
	    <p>To resolve BIF clashes, use explicit module names or the
	    <span class="code">{no_auto_import,[F/A]}</span> compiler directive.</p>
	    </p></div>
</div>
          </dd>

          <dt><strong><span class="code">{nowarn_bif_clash, FAs}</span></strong></dt>
          <dd>
            <p>This option is removed, it generates a fatal error if used.</p>

	    <div class="warning">
<div class="label">Warning</div>
<div class="content"><p>
	    <p>The use of this option has always been discouraged.
	    As from R14A, it is an error to use it.</p>
	    <p>To resolve BIF clashes, use explicit module names or the
	    <span class="code">{no_auto_import,[F/A]}</span> compiler directive.</p>
	    </p></div>
</div>
          </dd>

	  <dt><strong><span class="code">warn_export_all</span></strong></dt>
          <dd>
	      <p>Emits a warning if option <span class="code">export_all</span> is also given.</p>
          </dd>

	  <dt><strong><span class="code">warn_export_vars</span></strong></dt>
          <dd>
	    <p>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.</p>
          </dd>

	  <dt><strong><span class="code">nowarn_shadow_vars</span></strong></dt>
          <dd>
	      <p>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.</p>   
          </dd>

	  <dt><strong><span class="code">nowarn_unused_function</span></strong></dt>
          <dd>
            <p>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.</p>
          </dd>

	  <dt><strong><span class="code">{nowarn_unused_function, FAs}</span></strong></dt>
          <dd>
            <p>Turns off warnings for unused local functions like
              <span class="code">nowarn_unused_function</span> does, but only for the mentioned
              local functions. <span class="code">FAs</span> is a tuple <span class="code">{Name,Arity}</span>
              or a list of such tuples.</p>
          </dd>

	  <dt><strong><span class="code">nowarn_deprecated_function</span></strong></dt>
          <dd>
            <p>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 <span class="code">-deprecated()</span>, but uses an
	      assembled list of deprecated functions in Erlang/OTP. To
	      do a more general check, the <span class="code">Xref</span> tool can be used.
	      See also
	      <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','tools','xref.html#deprecated_function');">xref(3)</a></span>
              and the function
	      <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','tools','xref.html#m-1');">xref:m/1</a></span>, also
              accessible through the function 
	    <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','c.html#xm-1');">c:xm/1</a></span>.</p>
          </dd>

	  <dt><strong><span class="code">{nowarn_deprecated_function, MFAs}</span></strong></dt>
          <dd>
            <p>Turns off warnings for calls to deprecated functions like
	      <span class="code">nowarn_deprecated_function</span> does, but only for
	      the mentioned functions. <span class="code">MFAs</span> is a tuple
              <span class="code">{Module,Name,Arity}</span> or a list of such tuples.</p>
          </dd>

	  <dt><strong><span class="code">nowarn_deprecated_type</span></strong></dt>
          <dd>
            <p>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.</p>
          </dd>

	  <dt><strong><span class="code">warn_obsolete_guard</span></strong></dt>
          <dd>
            <p>Emits warnings for calls to old type testing BIFs, 
	    such as <span class="code">pid/1</span> and <span class="code">list/1</span>. See the
	    <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','doc/reference_manual','expressions.html#guards');">Erlang Reference Manual</a></span>
	      for a complete list of type testing BIFs and their old
	      equivalents. Default is to emit no warnings for calls to 
	      old type testing BIFs.</p>
          </dd>

	  <dt><strong><span class="code">warn_unused_import</span></strong></dt>
          <dd>
            <p>Emits warnings for unused imported functions. 
	    Default is to emit no warnings for unused imported functions.</p>
          </dd>

          <dt><strong><span class="code">nowarn_unused_vars</span></strong></dt>
          <dd>
            <p>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.</p>
          </dd>

	  <dt><strong><span class="code">nowarn_unused_record</span></strong></dt>
          <dd>
            <p>Turns off warnings for unused record types. Default is to 
	    emit warnings for unused locally defined record types.</p>
          </dd>
        </dl>

	<p>Another class of warnings is generated by the compiler
	  during optimization and code generation. They warn about
	  patterns that will never match (such as <span class="code">a=b</span>), guards
	  that always evaluate to false, and expressions that
	  always fail (such as <span class="code">atom+42</span>).</p>
	  <p>Those warnings cannot be disabled (except by
	  disabling all warnings).</p>

	  <div class="note">
<div class="label">Note</div>
<div class="content"><p>
	    <p>The compiler does not warn for expressions that it
          does not attempt to optimize. For example, the compiler tries
          to evaluate <span class="code">1/0</span>, detects that it will cause an
	  exception, and emits a warning. However,
	  the compiler is silent about the similar expression,
	  <span class="code">X/0</span>, because of the variable in it. Thus, the compiler does
	  not even try to evaluate and therefore it emits no warnings.</p>
          </p></div>
</div>

	<div class="warning">
<div class="label">Warning</div>
<div class="content"><p>
          <p>The absence of warnings does not mean that
	    there are no remaining errors in the code.</p>
        </p></div>
</div>
	
	<div class="note">
<div class="label">Note</div>
<div class="content"><p>
	<p>All options, except the include path
	  (<span class="code">{i,Dir}</span>), can also be given in the file with attribute
	  <span class="code">-compile([Option,...])</span>.
	  Attribute <span class="code">-compile()</span> is allowed after the function
	  definitions.</p>
	</p></div>
</div>
	
	<div class="note">
<div class="label">Note</div>
<div class="content"><p>
	<p>The options <span class="code">{nowarn_unused_function, FAs}</span>,
          <span class="code">{nowarn_bif_clash, FAs}</span>, and 
          <span class="code">{nowarn_deprecated_function, MFAs}</span> are only
          recognized when given in files. They are not affected by
	  options <span class="code">warn_unused_function</span>, <span class="code">warn_bif_clash</span>, or 
          <span class="code">warn_deprecated_function</span>.</p>
	</p></div>
</div>

        <p>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 <span class="code">compile:options()</span> at the Erlang shell prompt.
          The options are printed in the order that the passes are
	  executed. If more than one listing option is used, the one
	  representing the earliest pass takes effect.</p>

        <p>Unrecognized options are ignored.</p>

        <p>Both <span class="code">WarningList</span> and <span class="code">ErrorList</span> have
	  the following format:</p>
        <div class="example"><pre>
[{FileName,[ErrorInfo]}].</pre></div>

	<p><span class="code">ErrorInfo</span> is described later in this section. 
	The filename is included here, as the compiler uses the 
	Erlang pre-processor <span class="code">epp</span>, which allows the code to be 
	included in other files. It is therefore important to know to
	  <strong>which</strong> file the line number of an error or a warning refers.
	</p>
      </p></div>

    <p><a name="forms-1"><span class="bold_code">forms(Forms)</span></a><br></p>
<div class="REFBODY"><p>
        <p>Is the same as
	  <span class="code">forms(File, [verbose,report_errors,report_warnings])</span>.
	</p>
      </p></div>

    <p><a name="forms-2"><span class="bold_code">forms(Forms, Options) -&gt; CompRet</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Forms = [Form]</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">CompRet = BinRet | ErrRet</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">BinRet = {ok,ModuleName,BinaryOrCode} | {ok,ModuleName,BinaryOrCode,Warnings}</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">BinaryOrCode = binary() | term()</span><br>
</div>
        <div class="REFTYPES">
<span class="bold_code">ErrRet = error | {error,Errors,Warnings}</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Analogous to <span class="code">file/1</span>, but takes a list of forms (in
	  the Erlang abstract format representation) as first argument.
          Option <span class="code">binary</span> is implicit, that is, no object code
	  file is produced. For options that normally produce a listing 
	  file, such as 'E', the internal format for that compiler pass 
	  (an Erlang term, usually not a binary) is returned instead of 
	a binary.</p>
      </p></div>

    <p><a name="format_error-1"><span class="bold_code">format_error(ErrorDescriptor) -&gt; chars()</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">ErrorDescriptor = errordesc()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Uses an <span class="code">ErrorDescriptor</span> and returns a deep list of
	  characters that describes the error. This function is
	  usually called implicitly when an <span class="code">ErrorInfo</span> structure 
	(described in section 
	<span class="bold_code"><a href="#error_information">Error Information</a></span>) is processed.</p>
      </p></div>

    <p><a name="output_generated-1"><span class="bold_code">output_generated(Options) -&gt; true | false</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Options = [term()]</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Determines whether the compiler generates a <span class="code">beam</span>
	file with the given options. <span class="code">true</span> means that a <span class="code">beam</span>
	file is generated. <span class="code">false</span> means that the compiler
	generates some listing file, returns a binary, or merely
	checks the syntax of the source code.</p>
      </p></div>

    <p><a name="noenv_file-2"><span class="bold_code">noenv_file(File, Options) -&gt; CompRet</span></a><br></p>
<div class="REFBODY"><p>
      <p>Works like <span class="bold_code"><a href="#file-2">file/2</a></span>,
	 except that the environment variable <span class="code">ERL_COMPILER_OPTIONS</span>
	 is not consulted.</p>
      </p></div>

    <p><a name="noenv_forms-2"><span class="bold_code">noenv_forms(Forms, Options) -&gt; CompRet</span></a><br></p>
<div class="REFBODY"><p>
        <p>Works like <span class="bold_code"><a href="#forms-2">forms/2</a></span>,
	 except that the environment variable <span class="code">ERL_COMPILER_OPTIONS</span>
	 is not consulted.</p>
      </p></div>

    <p><a name="noenv_output_generated-1"><span class="bold_code">noenv_output_generated(Options) -&gt; true | false</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Options = [term()]</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>Works like
	<span class="bold_code"><a href="#output_generated-1">output_generated/1</a></span>,
	except that the environment variable <span class="code">ERL_COMPILER_OPTIONS</span>
	is not consulted.</p>
      </p></div>

  

  <h3><a name="idp307911196">Default Compiler Options</a></h3>
<div class="REFBODY">
    
    <p>The (host operating system) environment variable
      <span class="code">ERL_COMPILER_OPTIONS</span> can be used to give default compiler
      options. Its value must be a valid Erlang term. If the value is a
      list, it is used as is. If it is not a list, it is put
      into a list.</p>

      <p>The list is appended to any options given to
      <span class="bold_code"><a href="#file-2">file/2</a></span>,
      <span class="bold_code"><a href="#forms-2">forms/2</a></span>, and
      <span class="bold_code"><a href="#output_generated-1">output_generated/2</a></span>.
      Use the alternative functions
      <span class="bold_code"><a href="#noenv_file-2">noenv_file/2</a></span>,
      <span class="bold_code"><a href="#noenv_forms-2">noenv_forms/2</a></span>, or
      <span class="bold_code"><a href="#noenv_output_generated-1">noenv_output_generated/2</a></span>
      if you do not want the environment variable to be consulted,
      for example, if you are calling the compiler recursively from
      inside a parse transform.</p>
  </div>

  <h3><a name="idp307915068">Inlining</a></h3>
<div class="REFBODY">
    
    <p>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,
      <span class="code">function_clause</span> exceptions are converted to similar
      <span class="code">case_clause</span> exceptions.</p>

    <p>When a function is inlined, the original function is
      kept if it is exported (either by an explicit export or if the
      option <span class="code">export_all</span> was given) or if not all calls to the
      function are inlined.</p>
    
    <p>Inlining does not necessarily improve running time.
      For example, inlining can increase Beam stack use, which
      probably is detrimental to performance for recursive functions.
    </p>

    <p>Inlining is never default. It must be explicitly enabled with a
      compiler option or a <span class="code">-compile()</span> attribute in the source
      module.</p>

    <p>To enable inlining, either use the option <span class="code">inline</span> to
    let the compiler decide which functions to inline, or
    <span class="code">{inline,[{Name,Arity},...]}</span> to have the compiler inline
    all calls to the given functions. If the option is given inside
    a <span class="code">compile</span> directive in an Erlang module, <span class="code">{Name,Arity}</span>
    can be written as <span class="code">Name/Arity</span>.</p>

    <p>Example of explicit inlining:</p>

    <div class="example"><pre>
-compile({inline,[pi/0]}).

pi() -&gt; 3.1416.
    </pre></div>

    <p>Example of implicit inlining:</p>
    <div class="example"><pre>
-compile(inline).</pre></div>

    <p>The option <span class="code">{inline_size,Size}</span> controls how large functions
      that are allowed to be inlined. Default is <span class="code">24</span>, which
      keeps the size of the inlined code roughly the same as
      the un-inlined version (only relatively small functions are
      inlined).</p>

    <p>Example:</p>
    <div class="example"><pre>
%% Aggressive inlining - will increase code size.
-compile(inline).
-compile({inline_size,100}).</pre></div>
  </div>

  <h3><a name="idp308092404">Inlining of List Functions</a></h3>
<div class="REFBODY">
    
    <p>The compiler can also inline various list manipulation functions
      from the module <span class="code">list</span> in <span class="code">STDLIB</span>.</p>

    <p>This feature must be explicitly enabled with a compiler option or a
      <span class="code">-compile()</span> attribute in the source module.</p>

    <p>To enable inlining of list functions, use option <span class="code">inline_list_funcs</span>.</p>

    <p>The following functions are inlined:</p>
    <ul>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#all-2');">lists:all/2</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#any-2');">lists:any/2</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#foreach-2');">lists:foreach/2</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#map-2');">lists:map/2</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#flatmap-2');">lists:flatmap/2</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#filter-2');">lists:filter/2</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#foldl-3');">lists:foldl/3</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#foldr-3');">lists:foldr/3</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#mapfoldl-3');">lists:mapfoldl/3</a></span></li>
      <li><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','lists.html#mapfoldr-3');">lists:mapfoldr/3</a></span></li>
    </ul>
  </div>

  <h3><a name="idp308023068">Parse Transformations</a></h3>
<div class="REFBODY">
    

    <p>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.</p>
  </div>

  <h3><a name="idp308024220">Error Information</a></h3>
<div class="REFBODY">
    <a name="error_information"></a>
    

    <p>The <span class="code">ErrorInfo</span> mentioned earlier is the standard
      <span class="code">ErrorInfo</span> structure, which is returned from all I/O modules.
      It has the following format:</p>
    <div class="example"><pre>
{ErrorLine, Module, ErrorDescriptor}</pre></div>

    <p><span class="code">ErrorLine</span> is the atom <span class="code">none</span> if the error does
    not correspond to a specific line, for example, if the source file does
    not exist.</p>

    <p>A string describing the error is obtained with the following
      call:</p>
    <div class="example"><pre>
Module:format_error(ErrorDescriptor)</pre></div>
  </div>

  <h3><a name="idp308027236">See Also</a></h3>
<div class="REFBODY">
    
    <p>
      <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','epp.html');">epp(3)</a></span>,
      <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','erl_id_trans.html');">erl_id_trans(3)</a></span>,
      <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','erl_lint.html');">erl_lint(3)</a></span>,
      <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','beam_lib.html');">beam_lib(3)</a></span>
    </p>
  </div>
</div>
<div class="footer">
<hr>
<p>Copyright © 1997-2018 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>