How to avoid structure padding in C?
Answer Posted / santosh
Packing, on the other hand prevents compiler from doing padding - this has to be explicitly requested - under GCC it's __attribute__((__packed__)), so the following:
struct __attribute__((__packed__)) mystruct_A {
char a;
int b;
char c;
};
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Which is better between malloc and calloc?
How do you convert strings to numbers in C?
What is an lvalue in c?
What is pivot in c?
What is #line in c?
What is FIFO?
Can you please explain the scope of static variables?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
What are two dimensional arrays alternatively called as?
What is methods in c?
Can you apply link and association interchangeably?
What are the different types of data structures in c?
What is the difference between NULL and NUL?
What is a stream in c programming?
How do I use void main?