mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-27 14:24:08 +00:00
Rollup merge of #72605 - GuillaumeGomez:cleanup-e0617, r=Dylan-DPC
Add working example for E0617 explanation r? @Dylan-DPC
This commit is contained in:
commit
235f382731
@ -17,3 +17,14 @@ Certain Rust types must be cast before passing them to a variadic function,
|
||||
because of arcane ABI rules dictated by the C standard. To fix the error,
|
||||
cast the value to the type specified by the error message (which you may need
|
||||
to import from `std::os::raw`).
|
||||
|
||||
In this case, `c_double` has the same size as `f64` so we can use it directly:
|
||||
|
||||
```no_run
|
||||
# extern {
|
||||
# fn printf(c: *const i8, ...);
|
||||
# }
|
||||
unsafe {
|
||||
printf(::std::ptr::null(), 0f64); // ok!
|
||||
}
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user