为什么 `CMSG_SPACE` 不是 Rust 中的常量函数?

ber*_*oal 4 libc compile-time-constant rust

根据文档

pub const unsafe extern "C" fn CMSG_SPACE(length: c_uint) -> c_uint
Run Code Online (Sandbox Code Playgroud)

但是,如果我编译

fn main() {
    let _ = [0u8; libc::CMSG_SPACE(1) as usize];
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

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`.
Run Code Online (Sandbox Code Playgroud)

use*_*968 6

需要激活const-extern-fn 的功能才能libc 使该功能成为const。记录的版本docs.rs启用了此功能,这就是为什么它(不幸的是)显示为const默认情况。此功能需要每晚 rustc。