I have this helper function that I like to define so it looks like for one specific function
int change_int_val(unsigned int * from,unsigned int *to)
{
*to=*from;
return 0;
}
So actually it assign the from
to to
now the problem is I want to pass all fields that I have in my struct so assume I have struct iphdr
from networking and I want to assign value 5 to ihl which is 4 bit size defined as unsigned int ihl:4;
now if I call the above function like this
change_int_val((unsigned int *)5,(unsigned int *)(&ip->ihl));
I get error that
tcp_work.c:45:59: error: cannot take address of bit-field ‘ihl’
45 | change_int_val((unsigned int *)5,(unsigned int *)(&ip->ihl));
So can I make this helper function like the one above and escape this limitation that pointer size 1 byte issue with fields that are less than 1 byte in my case as I like to pass the address of iphdr->ihl
to my helper function change_int_val