9.6 -error() and -warning() directives
The directive -error(Term) causes a compilation error.
Example:
- -module(t).
- -export([version/0]).
- -ifdef(VERSION).
- version() -> ?VERSION.
- -else.
- -error("Macro VERSION must be defined.").
- version() -> "".
- -endif.
The error message will look like this:
- % erlc t.erl
- t.erl:7: -error("Macro VERSION must be defined.").
The directive -warning(Term) causes a compilation warning.
Example:
- -module(t).
- -export([version/0]).
- -ifndef(VERSION).
- -warning("Macro VERSION not defined -- using default version.").
- -define(VERSION, "0").
- -endif.
- version() -> ?VERSION.
The warning message will look like this:
- % erlc t.erl
- t.erl:5: Warning: -warning("Macro VERSION not defined -- using default version.").
The -error() and -warning() directives were added in OTP 19.