Skip to content

generate_cstr(true) results in weird spacing for long strings #3399

Description

@DanielEScherzer

With bindgen 0.72.1, the following code:

fn main() {
    let builder = bindgen::Builder::default()
        .header_contents(
            "php_config.h",
            r#"
#define PHP_OS "Linux"
#define PHP_BUILD_SYSTEM "Linux b355e0901ee6 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 GNU/Linux"
"#
        )
        .generate_cstr(true);

    let bindings = builder.generate().expect("Unable to generate bindings");

    bindings
        .write_to_file("bindings.rs")
        .expect("Couldn't write bindings!");
}

resulted in:

/* automatically generated by rust-bindgen 0.72.1 */

pub const PHP_OS: &::std::ffi::CStr = c"Linux";
pub const PHP_BUILD_SYSTEM : & :: std :: ffi :: CStr = c"Linux b355e0901ee6 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 GNU/Linux" ;

the spacing of & :: std :: ffi :: CStr for the second string looks odd, especially since the first string was done with &::std::ffi::CStr

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