Skip to content

Commit

Permalink
Replace 'if' preprocessor directive with 'ifndef', add OTP_BELOW_24
Browse files Browse the repository at this point in the history
The 'if' preprocessor directive was added in Erlang/OTP 21.0,
but ejabberd currently supports Erlang 20.0 and higher...
Let's use 'ifndef' instead.

https://www.erlang.org/doc/reference_manual/macros.html#flow-control-in-macros
https://www.erlang.org/doc/apps/compiler/notes#compiler-7.2
https://www.erlang.org/patches/otp-21.0#compiler-7.2
  • Loading branch information
badlop committed Feb 14, 2024
1 parent 5f78427 commit 007813a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ defmodule Ejabberd.MixProject do
if_version_below(~c"23", [{:d, :USE_OLD_PG2}]) ++
if_version_below(~c"24", [{:d, :COMPILER_REPORTS_ONLY_LINES}]) ++
if_version_below(~c"24", [{:d, :SYSTOOLS_APP_DEF_WITHOUT_OPTIONAL}]) ++
if_version_below(~c"24", [{:d, :OTP_BELOW_24}]) ++
if_version_below(~c"25", [{:d, :OTP_BELOW_25}])
defines = for {:d, value} <- result, do: {:d, value}
result ++ [{:d, :ALL_DEFS, defines}]
Expand Down
1 change: 1 addition & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
{if_version_below, "23", {d, 'USE_OLD_PG2'}},
{if_version_below, "24", {d, 'COMPILER_REPORTS_ONLY_LINES'}},
{if_version_below, "24", {d, 'SYSTOOLS_APP_DEF_WITHOUT_OPTIONAL'}},
{if_version_below, "24", {d, 'OTP_BELOW_24'}},
{if_version_below, "25", {d, 'OTP_BELOW_25'}},
{if_var_false, debug, no_debug_info},
{if_var_true, debug, debug_info},
Expand Down
2 changes: 1 addition & 1 deletion src/mod_matrix_gw.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
%%%----------------------------------------------------------------------

-module(mod_matrix_gw).
-if(?OTP_RELEASE >= 24).
-ifndef(OTP_BELOW_24).

-author('alexey@process-one.net').

Expand Down
2 changes: 1 addition & 1 deletion src/mod_matrix_gw_room.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
%%%-------------------------------------------------------------------
-module(mod_matrix_gw_room).

-if(?OTP_RELEASE >= 24).
-ifndef(OTP_BELOW_24).
-behaviour(gen_statem).

%% API
Expand Down
2 changes: 1 addition & 1 deletion src/mod_matrix_gw_s2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
%%%
%%%-------------------------------------------------------------------
-module(mod_matrix_gw_s2s).
-if(?OTP_RELEASE >= 24).
-ifndef(OTP_BELOW_24).
-behaviour(gen_statem).

%% API
Expand Down
2 changes: 1 addition & 1 deletion src/mod_matrix_gw_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
%%%
%%%----------------------------------------------------------------------
-module(mod_matrix_gw_sup).
-if(?OTP_RELEASE >= 24).
-ifndef(OTP_BELOW_24).
-behaviour(supervisor).

%% API
Expand Down

0 comments on commit 007813a

Please sign in to comment.