]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0617.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0617.md
1 Attempted to pass an invalid type of variable into a variadic function.
2
3 Erroneous code example:
4
5 ```compile_fail,E0617
6 extern {
7     fn printf(c: *const i8, ...);
8 }
9
10 unsafe {
11     printf(::std::ptr::null(), 0f32);
12     // error: cannot pass an `f32` to variadic function, cast to `c_double`
13 }
14 ```
15
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`).