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

Consider emitting the c-types provided by std/core, instead of depending on libc #294

Open
Luro02 opened this issue Sep 11, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@Luro02
Copy link

Luro02 commented Sep 11, 2020

The standard library provides std::os::raw, which defines c_*-types that can be used for ffi. Those types are identical to the types provided by libc.

It would be nice if c2rust would emit the types provided by the standard library, instead of depending on an external crate. (it is annoying to replace all occurences of libc::* with the std equivalent).

@ahomescu
Copy link
Contributor

The main thing to consider is that the std::os::raw types are only available with libstd but not in no_std mode, while the libc crate supports no_std.

It would be nice if c2rust would emit the types provided by the standard library, instead of depending on an external crate.

We could add an option --use-std-types to the transpiler, but I think we still need to support both sets of types. Alternatively, we could switch to std::os::raw types as the default and add an option for the libc types.

(it is annoying to replace all occurences of libc::* with the std equivalent).

The c2rust-refactor tool should be able to automate that, e.g., using rewrite_ty.

@ahomescu ahomescu self-assigned this Sep 11, 2020
@Luro02
Copy link
Author

Luro02 commented Sep 12, 2020

Relevant issue rust-lang/rust#36193

@ahomescu
Copy link
Contributor

@Luro02 I implemented this and created a pull request, feel free to use the std_raw_types branch while it gets reviewed.

@Luro02
Copy link
Author

Luro02 commented Sep 15, 2020

Very cool, thank you 🤗

@kkysen kkysen added the enhancement New feature or request label Jun 17, 2022
@kkysen kkysen changed the title Consider emitting the c-types provided by std, instead of depending on libc Consider emitting the c-types provided by std/core, instead of depending on libc Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants