【发布时间】:2018-04-26 07:21:31
【问题描述】:
Crate 可以重新导出它们所依赖的 crate。在此示例中,stm32f103xx-hal 板条箱执行以下操作:pub extern crate stm32f103xx;。
在我的代码中,我依赖于stm32f103xx-hal。现在我想使用由stm32f103xx crate 导出的interrupt!() 宏。我是否必须在我的 Cargo.toml 中添加 stm32f103xx crate 依赖项,还是有办法重新使用导出的 stm32f103xx-hal 定义?
请注意,这与简单的“如何使用来自不同 crate 的宏”是不同的问题。在stm32f103xx-hal 上声明#[macro_use(interrupt)] 会产生cannot find macro 'interrupt!' in this scope 错误。
【问题讨论】:
-
如果您像这样导入
stm32f103xx-hal,interrupt!()宏是否工作:#[macro_use] extern crate stm32f103xx-hal;? -
发现了一些关于现已失效的“macro_reexport”功能的额外讨论,这似乎与手头的问题非常相关:github.com/rust-lang/rust/issues/29638