Skip to content

Can't cope with *const () fields in structs. #654

@umanwizard

Description

@umanwizard

Example library:

use std::boxed::Box;

#[repr(C)]
pub struct S {
    x: *const ()
}

#[no_mangle]
pub extern "C" fn f() -> S {
    let s = Box::new(());
    unsafe { std::mem::transmute(s) }
}

output of cbindgen --lang c:

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct S S;

struct S f(void);

cbindgen was unable to generate struct S, presumably because it doesn't know what to make of *const (). Perhaps should be translated to C as a void const * ?

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