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

Small problem in const support of array initialization #593

Open
iulianR opened this issue Oct 7, 2020 · 1 comment
Open

Small problem in const support of array initialization #593

iulianR opened this issue Oct 7, 2020 · 1 comment

Comments

@iulianR
Copy link

iulianR commented Oct 7, 2020

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 #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!

@emilio
Copy link
Collaborator

emilio commented Oct 8, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants