在erlang中比较宏中的两个字符串时程序中的错误

时间:2017-01-17 05:42:47

标签: erlang erlang-shell

我已经写了宏来比较两个字符串如下

-module(helloworld). 
-export([start/0]). 
-define(macro1(X,Y),{if X == Y -> "True"; true ->"False" end.}). 

start() ->
   io:fwrite("~w",[?macro1("str","str")]).

得到如下错误:

Compiling the source code....
$erlc helloworld.erl 2>&1
helloworld.erl:6: syntax error before: '.'
helloworld.erl:2: function start/0 undefined

1 个答案:

答案 0 :(得分:4)

宏与功能定义不同。预处理器只需更换字符串。所以在你的情况下,你必须删除花括号中的点:

{{1}}