Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::os::windows::io::RawHandle exposes libc::HANDLE #24450

Closed
klutzy opened this issue Apr 15, 2015 · 3 comments
Closed

std::os::windows::io::RawHandle exposes libc::HANDLE #24450

klutzy opened this issue Apr 15, 2015 · 3 comments

Comments

@klutzy
Copy link
Contributor

klutzy commented Apr 15, 2015

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.)

@alexcrichton
Copy link
Member

I think that rust-lang/rfcs#1044 will fix this as it sets a vision for "raw" types and where they're defined and/or organized. In this case they'll be defined in the std::os::windows::raw where they'll be accessible.

@retep998
Copy link
Member

I'd be happy with just having c_void publicly accessible in std.

mattico pushed a commit to PistonDevelopers/hematite that referenced this issue May 13, 2015
[WIP] Fix #215 - Remove quack library usage

Not currently working, but progress has been made:
* cargo update
* flate (deprecated) -> flate2
* os::MemoryMap -> mmap
* rustc-serialize 0.2.8 -> 0.3.x
* range(a, b) -> a..b
* old_io -> io
* Other misc changes.

Add Mapper associated type.

Latest Changes.

Revert some trait changes.

This removes some of the changes I made while trying to understand what was going on. In its current form, the code is certianly *not* correct, but it's more correct than it was (BlockStates<R> vs BlockStates for example).

Fix misc errors
Thanks @eddyb!

Fix AsRawFd, WindowSettings builder pattern.

Fix window use.  Fix pub/mut in several places. Add NbtReaderError type for NbtReader to simplify errorr handling.

Fix all warnings and errors

Make changes as suggested by @eddyb

Linux build works now.

Fix Windows build.

Changes to the retep998 branch of mmap and adds libc from crates.io to deal with rust-lang/rust#24450.

Change Frame -> Output

Remove assets zip (oops)

Remove superfluous map.
@klutzy
Copy link
Contributor Author

klutzy commented Mar 31, 2016

This is fixed: liblibc doesn't have HANDLE anymore, and std::os::windows::raw::HANDLE is an alias of *mut c_void.
(Note that c_void itself is still an issue: #31536)

@klutzy klutzy closed this as completed Mar 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants