1 External C functions are allowed to be variadic. However, a variadic function
2 takes a minimum number of arguments. For example, consider C's variadic `printf`
6 use std::os::raw::{c_char, c_int};
9 fn printf(_: *const c_char, ...) -> c_int;
12 unsafe { printf(); } // error!
15 Using this declaration, it must be called with at least one argument, so
16 simply calling `printf()` is invalid. But the following uses are allowed:
19 # use std::os::raw::{c_char, c_int};
20 # #[cfg_attr(all(windows, target_env = "msvc"),
21 # link(name = "legacy_stdio_definitions",
22 # kind = "static", modifiers = "-bundle"))]
23 # extern "C" { fn printf(_: *const c_char, ...) -> c_int; }
26 use std::ffi::CString;
28 let fmt = CString::new("test\n").unwrap();
31 let fmt = CString::new("number = %d\n").unwrap();
32 printf(fmt.as_ptr(), 3);
34 let fmt = CString::new("%d, %d\n").unwrap();
35 printf(fmt.as_ptr(), 10, 5);