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

How to use bigger fields #45

Open
redeexpressos opened this issue Jul 31, 2024 · 1 comment
Open

How to use bigger fields #45

redeexpressos opened this issue Jul 31, 2024 · 1 comment

Comments

@redeexpressos
Copy link

#[bitfield(u64)]
#[derive(PartialEq)]
pub struct Message {
    #[bits(8)]
    pub message_id: u8,
    #[bits(24)]
    pub time_of_reception: u32,
    #[bits(3456)]
    pub payload: [u8; 432],
}

if i remove (u64), throws unknown type.

How can I use something this crate for bigger fields?

@redeexpressos redeexpressos changed the title How to use bigger bitfields How to use bigger fields Jul 31, 2024
@wrenger
Copy link
Owner

wrenger commented Aug 4, 2024

Unfortunately, u128 is the biggest bitfield size supported. Everything beyond has to be put into multiple bitfields, like:

#[bitfield(u128)]
struct A {
    // ...
}
#[bitfield(u128)]
struct B {
    // ...
}

#[repr(C)]
struct AB {
    a: A,
    b: B,
}

The same limitation applies to fields of bitfields.

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

No branches or pull requests

2 participants