我已经写了宏来比较两个字符串如下
-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
答案 0 :(得分:4)
宏与功能定义不同。预处理器只需更换字符串。所以在你的情况下,你必须删除花括号中的点:
{{1}}