cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

Small problem in const support of array initialization

Open iulianR opened this issue 5 years ago • 1 comments

Hello, I noticed that this doesn't work (cbindgen doesn't generate the struct definition):

const LENGTH: usize = 127;

#[repr(C)]
pub struct Data {
    pub d: [u8; LENGTH + 1],
}

After finding about https://github.com/eqrion/cbindgen/issues/53, I changed it to this and it now works:

const LENGTH: usize = 127 + 1;

#[repr(C)]
pub struct Data {
    pub d: [u8; LENGTH],
}

It's not such a big deal for me, but maybe it's worth investigating at some point. If it's trivial, let me know and I might make the change myself. Thanks!

iulianR avatar Oct 07 '20 15:10 iulianR

Yeah, I'd expect that to work. We should probably dig a bit where stuff is going wrong.

emilio avatar Oct 08 '20 11:10 emilio