define macro

在define macro中:

`", 替代"

`\`",替代\"

``,一边跟在macro变量前或后,表明不需要空格。

`define msg(x,y) `"x: `\`"y`\`"`"

$display(`msg(left,right));  扩展为 $diplay("x: \"y\"");

`define foo(f) f``_suffix

`foo(bar) 扩展为bar_suffix

如果macro的内容需要换行,则在后面加\,注意\后面不能有空格或其他字符。

`define func(x) \

  int func(x){\

    return x*x; \

  }

posted on 2019-10-14 17:02  lybinger  阅读(510)  评论(0)    收藏  举报

导航