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
What is infinite loop?
How do I create a directory? How do I remove a directory (and its contents)?
What is the return type of sizeof?
What do you understand by friend-functions? How are they used?
How do you determine whether to use a stream function or a low-level function?
What is formal argument?
Difference between strcpy() and memcpy() function?
What does *p++ do?
Can you apply link and association interchangeably?
Can we change the value of #define in c?
What is pass by reference in functions?
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
What is a rvalue?
write a program to concatenation the string using switch case?
What is the use of extern in c?