Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/26/02 13:59
Read: times


 
#23450 - formatted version: RE: struct size...
I'm using C51 v3.20, and when I compiled the following structure, the compiler allocates 6 bytes for it.
typedef struct t_channel_info {
	int target_temp:9;
	unsigned char control_mode:2;
	unsigned char status:2;
	unsigned char warming:1;
	int current_temp:9;
	unsigned char warm_proportion;
} t_channel_info;



Should not it allocate only (9+2+2+1+9+8)/8=4 bytes?

But, when I partition a 9-bit integer to 8 and 1 bits chars, the size reduces to 5 bytes.

Is there an explanation?


List of 3 messages in thread
TopicAuthorDate
struct size...            01/01/70 00:00      
formatted version: RE: struct size...            01/01/70 00:00      
RE: struct size...            01/01/70 00:00      

Back to Subject List