I am trying to part a int16_t variable inside a structure. This structure is persisted in disk and loaded back across reboot. the old structure is
struct details
{
int a;
int16_t var1;
int16_t b;
} details_t
The new one i changed is
struct details
{
int a;
int16_t var1:15;
unit16_t var2:1;
int16_t b;
}details_t;
The new changes are working fine across reboot.But is this correct way of doing?. what i want to achieve is to have a dual meaning of variable var1 based on var2 is set or cleared. since var2 stores binary values, I declared it as uint16_t. Is it legal to separate a variable and declare it as two different datatype (int16_t and uint16_t ). This is going to be the update in existing stack, which should work seamlessly after update. Also i couldn't use kernel functions like set_bit and clear_bit on these parted variables var1 and var2. My machine is little endian