Skip to content

Repr alignment attribute on shared structs #835

@dtolnay

Description

@dtolnay
#[cxx::bridge]
mod ffi {
    #[repr(align(4))]
    struct S {
        b: [u8; 4],
    }
}

Expected C++ header:

struct alignas(4) S {
  std::array<std::uint8_t, 4> b;
};

Currently the C++ code generator just errors on this attribute.

error[cxxbridge]: unrecognized repr
  ┌─ src/main.rs:3:12

3 │     #[repr(align(4))]
  │            ^^^^^^^^ unrecognized repr

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