We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi All,, How can i declare constant bit fields in a struct ?? struct mystruct{ unsigned char xx:6; unsigned char yy:2; }mystruct; Let us say i want mystruct.yy to be a constant 00, how can i do that ?? mystruct must be a 8-bit datatype. which of its two components xx and yy would be at MSB ?? If anyone can tell how to figure that out it would be great. Thankzz && Bye -Rocknmoon
struct mystruct { unsigned char xx:6; unsigned char const yy:2; } mystruct = { 3, 0 }; Would this struct take up 1 byte of storage space or 2 bytes on a low end 8051 architecture ??
Why ask if you can check yourself? I do C166, so I can't help you with that. Write a small program, run it in simulator, check sizeof(mystruct). It will take you 3 minutes. In the declaration of struct member the const qualifier doesn't mean it goes into ROM. A variable cannot be partly in ROM and partly in RAM. Regards, - Mike