在main.rs中使用以下代码,当我运行cargo test
时,在主函数中添加测试或`any语句时,它将返回错误代码176。它开始返回错误代码160。
#![no_std]
#![no_main]
#[cfg(test)]
#[macro_use]
extern crate std;
#[cfg(not(test))]
extern crate panic_halt;
#[no_mangle]
pub unsafe extern "C" fn main() {
}
从这个link我发现
Exit code 176 means "Unable to install on a network drive. Select another install location in your preferences and retry installing."
当我尝试通过lldb查找追溯时,它返回了
error: invalid thread
我找不到任何提及类似错误的线程,因此请在此处进行询问。
任何帮助表示赞赏。
每晚使用(nightly-x86_64-apple-darwin)
谢谢。
最佳答案
问题是您的main
函数,该函数的unix平台签名无效。它必须返回一个i32
(或更好的c_int
,但为简单起见,我们假定它们是标识性的)。
离开176
函数时,rax
只是main
寄存器中的一些随机值。
因此,将main
签名更改为:
pub unsafe extern "C" fn main() -> i32
并返回一个返回码(例如
0
表示成功)或者
pub unsafe extern "C" fn main() -> !
并在linux上使用
exit
syscall(或在嵌入式系统上使用无限循环)。
关于rust - 使用no_std进行的 cargo 测试失败,错误代码为176、160,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59410084/