Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jschwe opened this issue Feb 8, 2025 · 0 comments · May be fixed by #3122
Open

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

jschwe opened this issue Feb 8, 2025 · 0 comments · May be fixed by #3122

Comments

@jschwe
Copy link
Contributor

jschwe commented Feb 8, 2025

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,
}
@jschwe jschwe linked a pull request Feb 8, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant