Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
struct abc
{
int d;
int m;
int y;
}date;
if i use bit fields and suppose 33 bits are taking both date.d and date.m together
and date.m taking 16 bit than a new block of 32 bit memory created for storing 1 bit of date.d and date.m than did compiler will allocates remaing memory to date.y

What I have tried:

i have no idea wheter compiler allocates memory or not
Posted
Updated 11-Nov-17 18:04pm

1 solution

When you use bit fields in a struct, you get to specify the width of each field, but the compiler is free to arrange them in "storage units" as it sees fit. Different compilers will behave differently, but most will try to be "reasonable", so that things like machine registers and I/O device registers are mapped more or less intuitively.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900