1 Attempted to pass an invalid type of variable into a variadic function.
3 Erroneous code example:
7 fn printf(c: *const i8, ...);
11 printf(::std::ptr::null(), 0f32);
12 // error: cannot pass an `f32` to variadic function, cast to `c_double`
16 Certain Rust types must be cast before passing them to a variadic function,
17 because of arcane ABI rules dictated by the C standard. To fix the error,
18 cast the value to the type specified by the error message (which you may need
19 to import from `std::os::raw`).
21 In this case, `c_double` has the same size as `f64` so we can use it directly:
25 # fn printf(c: *const i8, ...);
28 printf(::std::ptr::null(), 0f64); // ok!