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

What's the right way to use errno?

611


What are external variables in c?

535


What is keyword in c?

584


Write a program in c to replace any vowel in a string with z?

676


What is chain pointer in c?

591






What does the error 'Null Pointer Assignment' mean and what causes this error?

730


Why do we use static in c?

623


Explain modulus operator. What are the restrictions of a modulus operator?

591


What are the complete rules for header file searching?

657


In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1368


Disadvantages of C language.

645


Explain the difference between #include "..." And #include <...> In c?

612


Why is python slower than c?

591


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

621


What is the difference between a function and a method in c?

549