当宏注释不能在定义它的同一编译中使用时,这意味着什么?

What does it mean when macro annotation cannot be used in the same compilation that defines it?

我很好奇这个说法:

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?

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

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.