Skip to content

__attribute__((aligned(2), packed)) generates both repr(packed) and repr(aligned) #2240

Open
@youknowone

Description

@youknowone

Input C/C++ Header

part of MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/hfs/hfs_format.h

#define int8_t char

struct FndrOpaqueInfo {
        int8_t opaque[16];
} __attribute__((aligned(2), packed));

Bindgen Invocation

$ bindgen has_format.h

Actual Results

#[repr(C, packed(2))]
#[repr(align(2))]
#[derive(Debug, Copy, Clone)]
pub struct FndrOpaqueInfo {
    pub opaque: [::std::os::raw::c_char; 16usize],
}

Expected Results

#[repr(C, packed(2))]
#[derive(Debug, Copy, Clone)]
pub struct FndrOpaqueInfo {
    pub opaque: [::std::os::raw::c_char; 16usize],
}

The actual result is illegal in Rust.

#[repr(C, packed(2))]
#[repr(align(2))]

any of below will be accepted

#[repr(C, packed(2))]
#[repr(C)]
#[repr(align(2))]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions