R
ranjeet.gupta
Dear All !!
Before i qoute my querry, I will like to qoute my analysis and my
Knowledge
Struct a {
int raw;
char data;
};
the size of above struct is 8 byte ... correct (I am talking of
32 bit procesor)
Struct a {
int raw;
char data_1;
char data_2;
};
again the size of above structure is 8 bytes.
Means the structure of padding is going on... right...
Now suppose I have to specefically allocate the 4 bits,
then What i will do is
strcut a {
cahr a:4;
}
now ideally speaking i should get the size of the above struct as
4 bits, But infact i will get the 1 byte, Again i run in the situation
that i dont want to allocate the extra 4 bits (which by default
structure is doing padding),
now my question comes.
First
how I am going to allocate the 4 bits only,
second (not directly realated to the above)
how i will assure that structure is alligned to the machine lenght ?
what i have to do in the structure that make me sure that it is
alligned to the machine word lenght.
I supposse that Strcuture padding is done to get the exectution of
Arthematic execution fast.... m i correct as it is alligned
to the machine length.
Please let me know about the above querry
Thanks In Advance
Ranjeet
Before i qoute my querry, I will like to qoute my analysis and my
Knowledge
Struct a {
int raw;
char data;
};
the size of above struct is 8 byte ... correct (I am talking of
32 bit procesor)
Struct a {
int raw;
char data_1;
char data_2;
};
again the size of above structure is 8 bytes.
Means the structure of padding is going on... right...
Now suppose I have to specefically allocate the 4 bits,
then What i will do is
strcut a {
cahr a:4;
}
now ideally speaking i should get the size of the above struct as
4 bits, But infact i will get the 1 byte, Again i run in the situation
that i dont want to allocate the extra 4 bits (which by default
structure is doing padding),
now my question comes.
First
how I am going to allocate the 4 bits only,
second (not directly realated to the above)
how i will assure that structure is alligned to the machine lenght ?
what i have to do in the structure that make me sure that it is
alligned to the machine word lenght.
I supposse that Strcuture padding is done to get the exectution of
Arthematic execution fast.... m i correct as it is alligned
to the machine length.
Please let me know about the above querry
Thanks In Advance
Ranjeet