diff options
author | Björn Gustavsson <[email protected]> | 2015-10-01 15:41:01 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-05-04 13:04:38 +0200 |
commit | 14d72f02146b1d0aa3293eef9a823cbf0f4a4e99 (patch) | |
tree | e2e8285201f283e26cd44d06aeac04b909f5e45b /erts/obj | |
parent | d035b0cbaeb4f276b3d13613c1564ae7c90400e7 (diff) | |
download | otp-14d72f02146b1d0aa3293eef9a823cbf0f4a4e99.tar.gz otp-14d72f02146b1d0aa3293eef9a823cbf0f4a4e99.tar.bz2 otp-14d72f02146b1d0aa3293eef9a823cbf0f4a4e99.zip |
epp: Add the -error and -warning directives
If one of several alternatives configurations are required for
an Erlang module to compile, but none are available, it would
be useful to give a nice error message. For example:
-ifdef(CONFIG_A).
%% Some code if A is true.
-else.
-ifdef(CONFIG_B).
%% Some code if B is true.
-else.
-error("Neither CONFIG_A nor CONFIG_B are available").
-endif.
-endif.
If neither CONFIG_A nor CONFIG_B are defined, the error message
will be:
module.erl:10: -error("Neither CONFIG_A nor CONFIG_B are available").
That is basically the same behavior as for the #error directive in
GCC.
For symmetry with the -error directive, add the -warning
directive to generate a compiler warning. For example:
-ifdef(HAVE_COOL_FEATURE).
%% Code if we have Cool Feature.
-else.
%% Inefficient fallback code.
-warning("Using inefficient fallback").
-endif.
If HAVE_COOL_FEATURE is not defined, the warning message will
be:
module.erl:8: Warning: -warning("Using inefficient fallback").
That is basically the same behavior as for the #warning directive
in GCC.
Conflicts:
lib/stdlib/src/epp.erl
lib/stdlib/test/epp_SUITE.erl
Diffstat (limited to 'erts/obj')
0 files changed, 0 insertions, 0 deletions