我很好奇这句话:
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.
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|