File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
compiler/rustc_error_codes/src/error_codes Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ Erroneous code example:
4
4
5
5
``` compile_fail,E0617
6
6
extern "C" {
7
- fn printf(c: *const i8 , ...);
7
+ fn printf(c: *const u8 , ...) -> std::os::raw::c_int ;
8
8
}
9
9
10
10
unsafe {
11
- printf(::std::ptr::null (), 0f32 );
11
+ printf("my favourite number is %f".as_ptr (), 4_f32 );
12
12
// error: cannot pass an `f32` to variadic function, cast to `c_double`
13
13
}
14
14
```
@@ -22,9 +22,9 @@ In this case, `c_double` has the same size as `f64` so we can use it directly:
22
22
23
23
``` no_run
24
24
# extern "C" {
25
- # fn printf(c: *const i8 , ...);
25
+ # fn printf(c: *const u8 , ...) -> std::os::raw::c_int ;
26
26
# }
27
27
unsafe {
28
- printf(::std::ptr::null (), 0f64 ); // ok!
28
+ printf("my favourite number is %f".as_ptr (), 4_f64 ); // ok!
29
29
}
30
30
```
You can’t perform that action at this time.
0 commit comments