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

Empty structs should not need #[repr(C)] #750

Closed
steveklabnik opened this issue Jan 27, 2015 · 3 comments
Closed

Empty structs should not need #[repr(C)] #750

steveklabnik opened this issue Jan 27, 2015 · 3 comments
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@steveklabnik
Copy link
Member

Issue by cgaebel
Thursday Nov 06, 2014 at 07:50 GMT

For earlier discussion, see rust-lang/rust#18686

This issue was labelled with: in the Rust repository


In a lot of FFI code, I see patterns like:

struct X {}

fn some_c_function(this: *mut X);

where X is used as an opaque "black-box" object. With rust today, X needs a #[repr(C)]. That's not really necessary, and caused a bunch of noisy warnings when updating servo's rust version.

Can someone mark this bug as easy so a beginner can use it to get started?

@dgrunwald
Copy link
Contributor

Empty structs do not exist in C, and it is not clear what their representation should be.
In C with GCC extensions, sizeof(empty_struct) == 0. But in C++, sizeof(empty_struct) == 1.

For the case of incomplete types in C headers, something like RFC #709 unsized types would be a better fit.

@scottmcm
Copy link
Member

This is now covered by extern type, #1861.

@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the RFC. label Feb 23, 2018
@Centril
Copy link
Contributor

Centril commented Feb 23, 2018

Closing per @scottmcm's comment.

@Centril Centril closed this as completed Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

4 participants