Rohit kumar Chandel wrote:
[Top-posting and failure to remove sigs corrected]
> Thanks for the info.
> Another question. I have read somewhere concept of byte boundaries in
> context of Structure padding. But could get nothing out of it since no
> explaination was provided as what is byte boundary.
Although a system may allow byte-level addressing, it's unlikely that
data types can start at arbitrary byte addresses. So data types have to
be aligned at addresses which meet specific requirements.
For example, on the PowerPC systems I've worked on, 32-bit data items
(e.g. ints on that system) had to be at addresses which were multiples
of 4-bytes while 64-bit data items (longs, doubles) had to be at 8-byte
boundaries... As a structure could start with any data type, structures
were also 8-byte aligned, as was memory returned by malloc().
In this model a structure of the form :-
struct fred {
char a;
long b;
};
would have 7-bytes of padding between a and b.