小编Cre*_*oat的帖子

使用基于 LLVM 的工具(clang、Rust、Zig)为 N64 进行编译

I\xe2\x80\x99m 尝试使用基于 LLVM 的zig cc为 R4300i / VR4300 MIPS CPU(N64 中的处理器)编译 C 代码(最终还有其他基于 LLVM 的语言,如 Rust/Zig)。但我没有看到任何以 VR4300 作为目标进行编译的证据或示例:

\n
    \n
  • 我见过的编译指南/工具\xe2\x80\x99都指导使用GCC / IDO进行编译,没有提到基于LLVM的C编译器(甚至没有提到像clang这样的更主流的编译器)。
  • \n
  • 我没有看到它列在 中zig targets
  • \n
  • 我没有看到任何方法来列出可用于 LLVM 的有效目标。
  • \n
\n

LLVM不支持VR4300作为编译目标吗?我怎样才能自己发现这一点?

\n

mips llvm clang rust zig

5
推荐指数
0
解决办法
338
查看次数

循环中的可变借用

我的代码:

struct Foo<'a> {
    bytes: &'a mut [u8],
}

impl<'a> Foo<'a> {
    fn bar<'b>(&'b mut self) {
        self.bytes = &mut self.bytes[1..];
    }
}

fn baz<'a, 'b>(foo: &'b mut Foo<'a>) {
    println!("baz!");
    
    for _ in 0..3 {
        foo.bar();
    }
}
Run Code Online (Sandbox Code Playgroud)

也在Rust Playground 中

这会导致以下错误回溯:

   Compiling playground v0.0.1 (/playground)
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements
  --> src/main.rs:12:27
   |
12 |         self.bytes = &mut self.bytes[1..];
   |                           ^^^^^^^^^^^^^^^
   |
note: first, the …
Run Code Online (Sandbox Code Playgroud)

reference lifetime rust

0
推荐指数
1
解决办法
231
查看次数

标签 统计

rust ×2

clang ×1

lifetime ×1

llvm ×1

mips ×1

reference ×1

zig ×1