Click here to Skip to main content
13,456,879 members
Rate this:
Please Sign up or sign in to vote.
See more:
struct abc
int d;
int m;
int y;
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 11-Nov-17 15:08pm
Updated 11-Nov-17 18:04pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180322.1 | Last Updated 12 Nov 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100