int readint(__packed int *data)
{
return *data;
}
I have seen __packed
attribute in struct
declarations to avoid padding. However, what is the benefit of using __packed
attribute in function arguments.
The author says that he has used __packed
to tell the compiler that the integer may possibly not be aligned. What does it means?
Edit: Will the following work with gcc
compiler
int readint(__attribute__((packed)) int *data)
{
return *data;
}