我有以下目录结构
/main.rs/lib.rs/tutorial/mod.rs/tutorial/foo.rs在foo.rs我需要使用glium库中的宏,implement_vertex!.如果我放在#[macro_use] extern crate glium;头上foo.rs,我会得到一个error: an `extern crate` loading macros must be at the crate root.我也得到了error: macro undefined: 'implement_vertex!'
还有一个lib.rs是教程模块的包根.我需要放在#[macro_use]那里.如果我同时拥有它们main.rs,这会创建2个箱子根lib.rs吗?
在子模块中导入宏的正确方法是什么?
我正在努力解决如何从外部箱子导入宏的问题.在我的主要人员中,我正在进口Glium箱子:
#![macro_use]
extern crate glium;
pub use glium::*;
// where my actual main function will be done from
mod part01drawtriangle;
fn main() {
part01drawtriangle::main();
}
Run Code Online (Sandbox Code Playgroud)
在我的主要功能来自我的另一个文件中,我从该包中调用了一个宏:
pub fn main() {
implement_vertex!(Vertex, position);
}
Run Code Online (Sandbox Code Playgroud)
构建时,我收到错误消息:
error: macro undefined: 'implement_vertex!'
Run Code Online (Sandbox Code Playgroud)