ScalaMacros和Eclipse [英] ScalaMacros and Eclipse
问题描述
我正在尝试使用适用于Scala 2.10.0-M3的Scala IDE插件在Eclipse 3.7.2中编译一个(Scala)宏,但是遇到以下错误:
I am trying to compile a (Scala) macro in Eclipse 3.7.2 with the Scala IDE Plugin available for Scala 2.10.0-M3, but I am experiencing the following error:
找不到宏实现:XXXXX(最常见的原因是,您不能在定义宏实现的同一编译运行中使用宏实现),如果您确实需要与其他宏一起定义宏实现程序,请考虑在第二阶段使用-Xmacro-fallback-classpath进行两阶段编译,指向第一阶段的输出.
我已经知道如何使用简单的编辑器和终端(仅遵循错误消息)来避免这种情况,但是有可能在Eclipse中实现双阶段任务吗?
I already know how to avoid it with a simple editor and a terminal (just following the error message), but is it possible to achieve the dual phase task in Eclipse?
推荐答案
如何创建宏项目以链接到现有项目:
How to create a macro project to link to an existing project:
- 创建一个名为例如
ProjectMacros
的scala项目,并在其中放入一个包含例如宏的名为Macros.scala
的文件.该项目应该编译没有问题,因为只有宏. - 在现有的Scala项目,然后单击属性"单击鼠标右键. 属性"窗口打开.
- 在
Java Build Path
部分中:- 在的标签
添加 - 在选项卡
Libraries
下,单击Add Class Folder
,然后选择ProjectMacros/bin
目录.
- Create a scala project named for example
ProjectMacros
, put a file named for exampleMacros.scala
containing macros in it. This project should compile without problems, because there are only macros. - Right-click on the existing scala project, then "Properties". The Properties window opens.
- In the
Java Build Path
section:- Under the tab
Projects
, addProjectMacros
. - Under the tab
Libraries
, clickAdd Class Folder
, and select theProjectMacros/bin
directory.
现在,在现有项目中添加
import Macros._
之类的导入后,您可以使用宏功能和注释.Now, after adding in the existing project an import like
import Macros._
you can use the macros functions and annotations.这篇关于ScalaMacros和Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Under the tab
- 在的标签