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

Take advantage of feature(core_ffi_c) (and possibly feature(c_size_t)) #2231

Closed
ojeda opened this issue Jun 30, 2022 · 2 comments · Fixed by #2267
Closed

Take advantage of feature(core_ffi_c) (and possibly feature(c_size_t)) #2231

ojeda opened this issue Jun 30, 2022 · 2 comments · Fixed by #2267

Comments

@ojeda
Copy link

ojeda commented Jun 30, 2022

feature(core_ffi_c) was stabilized (and possibly feature(c_size_t) in the future), so we may want to extend --use-core to use them (gated on --rust-target or some other flag).

In fact, it could potentially be made the default, since it would work for all projects (i.e. both std and no_std).

Currently, a workaround is to manually specify the prefix via --ctypes-prefix core::ffi.

Input C/C++ Header

void f(int);

Bindgen Invocation

$ bindgen input.h --use-core

Or in the future:

$ bindgen input.h

Actual Results

extern "C" {
    pub fn f(arg1: ::std::os::raw::c_int);
}

Expected Results

extern "C" {
    pub fn f(arg1: ::core::ffi::c_int);
}
@emilio
Copy link
Contributor

emilio commented Jul 25, 2022

Yes, making this the default based on the rust target seems like a great path forward. It seems core_ffi_c got stabilized already? A patch for this should be easy-ish to write / review :)

@ojeda
Copy link
Author

ojeda commented Jul 25, 2022

Yeah, I have piled up a few things for bindgen that I want to take a look at and submit -- I should have some time in a week or so :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants