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

c_void seems problematic #20274

Closed
tomjakubowski opened this issue Dec 28, 2014 · 2 comments
Closed

c_void seems problematic #20274

tomjakubowski opened this issue Dec 28, 2014 · 2 comments
Labels
A-FFI Area: Foreign function interface (FFI) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

Comments

@tomjakubowski
Copy link
Contributor

From the docs: http://doc.rust-lang.org/libc/types/common/c95/enum.c_void.html

For LLVM to recognize the void pointer type and by extension functions like malloc(), we need to have it represented as i8* in LLVM bitcode. The enum used here ensures this and prevents misuse of the "raw" type by only having private variants.

Since Rust lost private variants months ago, perhaps another approach should be considered.

@tomjakubowski
Copy link
Contributor Author

It could probably be rewritten as:

#[repr(u8)]
enum c_void_inner {
    __variant1,
    __variant2
}

#[repr(u8)]
pub struct c_void(c_void_inner);

But I don't know if this will actually be treated the same by LLVM.

@kmcallister kmcallister added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-FFI Area: Foreign function interface (FFI) labels Jan 16, 2015
@steveklabnik
Copy link
Member

moved to rust-lang/libc#48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-FFI Area: Foreign function interface (FFI) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
Projects
None yet
Development

No branches or pull requests

3 participants