File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ void hello() {
252
252
// Note the lack of the `#[link]` attribute. We’re delegating the responsibility
253
253
// of selecting what to link over to the build script rather than hard-coding
254
254
// it in the source file.
255
- extern { fn hello(); }
255
+ unsafe extern { fn hello(); }
256
256
257
257
fn main() {
258
258
unsafe { hello(); }
@@ -327,7 +327,7 @@ Let's round out the example with a basic FFI binding:
327
327
328
328
use std::os::raw::{c_uint, c_ulong};
329
329
330
- extern "C" {
330
+ unsafe extern "C" {
331
331
pub fn crc32(crc: c_ulong, buf: *const u8, len: c_uint) -> c_ulong;
332
332
}
333
333
Original file line number Diff line number Diff line change @@ -766,7 +766,7 @@ pub struct SpecificLayout {
766
766
// Example usage that will break.
767
767
use updated_crate::SpecificLayout;
768
768
769
- extern "C" {
769
+ unsafe extern "C" {
770
770
// This C function is assuming a specific layout defined in a C header.
771
771
fn c_fn_get_b(x: &SpecificLayout) -> u32;
772
772
}
@@ -820,7 +820,7 @@ pub struct SpecificLayout {
820
820
// Example usage that will break.
821
821
use updated_crate::SpecificLayout;
822
822
823
- extern "C" {
823
+ unsafe extern "C" {
824
824
// This C function is assuming a specific layout defined in a C header.
825
825
fn c_fn_get_b(x: &SpecificLayout) -> u32; // Error: is not FFI-safe
826
826
}
@@ -941,7 +941,7 @@ pub struct Transparent<T>(T);
941
941
#![deny(improper_ctypes)]
942
942
use updated_crate::Transparent;
943
943
944
- extern "C" {
944
+ unsafe extern "C" {
945
945
fn c_fn() -> Transparent<f64>; // Error: is not FFI-safe
946
946
}
947
947
You can’t perform that action at this time.
0 commit comments