va_list-rs 0.0.4

Library to handle va_list
Documentation
  • Coverage
  • 33.33%
    1 out of 3 items documented0 out of 0 items with examples
  • Size
  • Source code size: 12.38 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 555.58 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • GuillaumeGomez/va_list-rs
    2 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • GuillaumeGomez

va_list-rs Build Status Build status

A way to use C va_list from Rust.

Example:

extern crate libc;
#[macro_use] extern crate va_list;

use libc::{c_char, c_int};

// Here we declare the C function with va_list that we'll use.
extern "C" {
    fn vprintf(f: *const c_char, v: va_list::va_list) -> c_int;
}

fn main() {
    // You just have to call this macro and it'll return you the va_list.
    unsafe {
        to_va_list!(|v: va_list::va_list| {
            // And now you can just give the va_list to the C function:
            vprintf(b"%d %d %s\n\0".as_ptr() as *const c_char, v);
        },
        1, 2, b"salut!\0".as_ptr()); // We pass the arguments after the closure.
    }
}