-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Description
std::os::windows::io::RawHandle
is a re-export of libc::HANDLE = *mut libc::c_void
, and c_void
is defined as enum.
So it's possible to access non-primitive type of liblibc via std
. This leads to confusing error if someone uses both RawHandle
and crates.io's liblibc:
// use libc from crates.io
extern crate libc;
use std::os::windows::io::AsRawHandle;
fn get_handle(file: File) {
let handle = file.as_raw_handle();
// error: mismatched types: expected `*mut libc::types::common::c95::c_void`,
// found `*mut libc::types::common::c95::c_void`
// let handle: libc::HANDLE = handle;
// explicit casting needed
let handle: libc::HANDLE = handle as libc::HANDLE;
}
(On unix, std::os::unix::io::RawFd
is re-export of libc::c_int
, which is re-export of primitive type.)
Metadata
Metadata
Assignees
Labels
No labels