logo
  • 教程列表
  • SO官方文檔
  • 外部函式介面(FFI)
    • 從夜間生鏽呼叫 libc 功能
  1. StackOverflow 文件
  2. Rust 教程
  3. 外部函式介面(FFI)
  4. 從夜間生鏽呼叫 libc 功能

從夜間生鏽呼叫 libc 功能

Created: November-22, 2018

libc 箱是’ 特色門控 ‘,只能在夜間 Rust 版本上訪問,直到它被認為是穩定的。

#![feature(libc)]
extern crate libc;
use libc::pid_t;

#[link(name = "c")]
extern {
    fn getpid() -> pid_t;
}

fn main() {
    let x = unsafe { getpid() };
    println!("Process PID is {}", x);
}
  • 外部函式介面(FFI)

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明