aboutsummaryrefslogtreecommitdiffstats
path: root/system/doc/reference_manual
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-05-09 07:37:47 +0200
committerBjörn Gustavsson <[email protected]>2016-05-09 07:37:47 +0200
commit74df1712e9c89e0b47422e5d4ec28588c19c0450 (patch)
tree695beb0659e61e69150d7275811e1c402497307d /system/doc/reference_manual
parentfbc2d05c2659debff1c78d989b6921a3fff6037b (diff)
parent1470e950a722d8369ef5ec7410cb47c0e083b52f (diff)
downloadotp-74df1712e9c89e0b47422e5d4ec28588c19c0450.tar.gz
otp-74df1712e9c89e0b47422e5d4ec28588c19c0450.tar.bz2
otp-74df1712e9c89e0b47422e5d4ec28588c19c0450.zip
Merge branch 'bjorn/stdlib/warning-and-error/OTP-13476'
* bjorn/stdlib/warning-and-error/OTP-13476: Add documentation epp: Add the -error and -warning directives epp: Refactor expansion of header path
Diffstat (limited to 'system/doc/reference_manual')
-rw-r--r--system/doc/reference_manual/macros.xml48
1 files changed, 48 insertions, 0 deletions
diff --git a/system/doc/reference_manual/macros.xml b/system/doc/reference_manual/macros.xml
index 42ea639b54..350bb1d123 100644
--- a/system/doc/reference_manual/macros.xml
+++ b/system/doc/reference_manual/macros.xml
@@ -234,6 +234,53 @@ or
</section>
<section>
+ <title>-error() and -warning() directives</title>
+
+ <p>The directive <c>-error(Term)</c> causes a compilation error.</p>
+
+ <p><em>Example:</em></p>
+ <code type="none">
+-module(t).
+-export([version/0]).
+
+-ifdef(VERSION).
+version() -> ?VERSION.
+-else.
+-error("Macro VERSION must be defined.").
+version() -> "".
+-endif.</code>
+
+ <p>The error message will look like this:</p>
+
+ <pre>
+% <input>erlc t.erl</input>
+t.erl:7: -error("Macro VERSION must be defined.").</pre>
+
+ <p>The directive <c>-warning(Term)</c> causes a compilation warning.</p>
+
+ <p><em>Example:</em></p>
+ <code type="none">
+-module(t).
+-export([version/0]).
+
+-ifndef(VERSION).
+-warning("Macro VERSION not defined -- using default version.").
+-define(VERSION, "0").
+-endif.
+version() -> ?VERSION.</code>
+
+ <p>The warning message will look like this:</p>
+
+ <pre>
+% <input>erlc t.erl</input>
+t.erl:5: Warning: -warning("Macro VERSION not defined -- using default version.").</pre>
+
+ <p>The <c>-error()</c> and <c>-warning()</c> directives were added
+ in OTP 19.</p>
+
+ </section>
+
+ <section>
<title>Stringifying Macro Arguments</title>
<p>The construction <c>??Arg</c>, where <c>Arg</c> is a macro
argument, is expanded to a string containing the tokens of
@@ -253,5 +300,6 @@ io:format("Call ~s: ~w~n",["you : function ( 2 , 1 )",you:function(2,1)]).</code
<p>That is, a trace output, with both the function called and
the resulting value.</p>
</section>
+
</chapter>