Skip to content

#[repr(align(n), C)] and #[repr(packed, C)] are not represented correctly #430

@cyphar

Description

@cyphar

#[repr(align(n), C)] markers on a struct should be translated to __attribute__((align(n)), similarly for #[repr(packed, C)] for __attribute__((packed)). Right now they are generated as being opaque structs. This is necessary to implement a Rust-based __attribute__((packed)) (by setting #[repr(align(1))]).

Additionally, #[repr(align(n))] and #[repr(C)] separately applied on the same struct (which AFAIK is equivalent to #[repr(align(n), C)]) will result in the structure being generated as a non-opaque struct but with the wrong alignment (resulting in C code passing incorrect structs to Rust code -- which won't end well).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions