为什么 `CMSG_SPACE` 不是 Rust 中的常量函数?
Why is `CMSG_SPACE` not a constant function in Rust?
pub const unsafe extern "C" fn CMSG_SPACE(length: c_uint) -> c_uint
但是,如果我编译
fn main() {
let _ = [0u8; libc::CMSG_SPACE(1) as usize];
}
我收到以下错误:
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/bin/libc-const.rs:2:27
|
2 | let _ = [0u8; unsafe {libc::CMSG_SPACE(1) as usize}];
| ^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0015`.
const-extern-fn
feature for libc
is required 激活此功能 const
。 docs.rs
上记录的版本启用了此功能,这就是它(不幸地)默认显示为 const
的原因。此功能需要每晚 rustc。
pub const unsafe extern "C" fn CMSG_SPACE(length: c_uint) -> c_uint
但是,如果我编译
fn main() {
let _ = [0u8; libc::CMSG_SPACE(1) as usize];
}
我收到以下错误:
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/bin/libc-const.rs:2:27
|
2 | let _ = [0u8; unsafe {libc::CMSG_SPACE(1) as usize}];
| ^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0015`.
const-extern-fn
feature for libc
is required 激活此功能 const
。 docs.rs
上记录的版本启用了此功能,这就是它(不幸地)默认显示为 const
的原因。此功能需要每晚 rustc。