I have a C struct defined as:
struct my_c_s {
u_char *ptr;
unsigned flag_a:1;
unsigned flag_b:1;
int some_num;
}
How would flag_a
and flag_b
be represented?
#[repr(C)]
pub struct my_rust_s {
pub ptr: *const u_char,
//pub flag_a: ?,
//pub flag_b: ?,
pub some_num: ::libc::c_int,
}
Can I declare them as bool
s? Or does that whole thing need to be some sort of set of bits with a single field, and then I bitmask them out?
e.g. pub flag_bits: ::libc::c_uint,
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…