Skip to content

Comments are not generated for typedef struct forward declaration. #3119

Description

@jschwe

If we have a struct declaration with a typedef and the same name, the comment is not generated on the Rust binding.

/**
 * This is a forward declared struct with typedef
 */
typedef struct Struct2 Struct2;

binding:

#[repr(C)]
pub struct Struct2 {
    _unused: [u8; 0],
}

If we change the C typedef to have a non conflicting name:

/**
 * This is forward declared struct alias
 */
typedef struct Struct2 Struct2_alias;

The comment is generated on top of the type alia:

#[repr(C)]
pub struct Struct2 {
    _unused: [u8; 0],
}
/// This is forward declared struct alias
pub type Struct2_alias = Struct2;

If we add a field to the struct, then the comment is also correctly generated:

/**
 * This is forward declared struct alias
 */
typedef struct Struct2 {
    /**
     * This is field
     */
    int field;
} Struct2;
/// This is forward declared struct alias
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Struct2 {
    /// This is field
    pub field: ::std::os::raw::c_int,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions