加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 当宏注释无法在定义它的同一编译中使用时,这意味着什么

发布时间:2020-12-16 10:00:11 所属栏目:安全 来源:网络整理
导读:我很好奇这句话: Error:(3,18) …another possibility is that you try to use macro annotation in the same compilation run that defines it) 我试过谷歌搜索,发现这个: Finally,remember that using macros requires compilation to happen in two ste
我很好奇这句话:

Error:(3,18) …another possibility is that you try to use macro
annotation in the same compilation run that defines it)

我试过谷歌搜索,发现这个:

Finally,remember that using macros requires compilation to happen in two steps: first,compile the macros,then compile the code where the macros are used. This is necessary so that your macros can be run before the rest of your code is compiled. For example if you use SBT,you can configure Build.scala to use two modules,a “macros” module containing your macros,and a “root” module that depends on the “macros” module.

这是否意味着宏定义需要在其自己的独立模块中使用?我如何在build.scala中定义它,以便宏模块在另一个之前编译?

解决方法

Does this mean that the macro definitions need to be in its own separate module to be used?

是.请注意,宏定义可以在同一模块的测试中,因为它们是在主代码之后编译的.

And how do I define it in the build.scala so that the macro module compiles before the other?

Just add dependsOn(<module-which-contains-macros>) to <module-which-uses-them>‘s definition.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读