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


Please Help Members By Posting Answers For Below Questions

write a proram to reverse the string using switch case?

2560


Define the scope of static variables.

697


What is the function of volatile in c language?

756


what is recursion in C

707


What is an lvalue?

728






1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

3289


When should a type cast not be used?

705


How main function is called in c?

711


What is a void pointer? When is a void pointer used?

723


What is a pointer variable in c language?

734


What should malloc() do?

736


What is data structure in c programming?

667


What are the types of operators in c?

709


Write a function that will take in a phone number and output all possible alphabetical combinations

694


What is switch in c?

741