Skip to content

Issues with repr(C) trait #21

Closed
Closed
@clegaard

Description

@clegaard

I am writing some code that needs to be callable from C. To my understanding enums exposed to the c code should have the trait #[repr(C)], but this seems to cause an issue with the module:

#[repr(C)]
pub enum Okay {
    a,

#[derive(TryFromPrimitive)]
#[repr(C)]
pub enum NotOkay {
    a,
}

Produces the error:

error: repr(C) doesn't have a well defined size
   --> src\lib.rs:124:8
    |
124 | #[repr(C)]
    |        ^

Is there a workaround for this? I tried defining multiple types: #[repr(C,i32)] which appears to have been possible previously: rust-lang/rust#68585

Any help is much appreciated :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions