[ back to toc ]

C data structures

Date: 2002/05/25 10:56

Q:
I have declared a 1-byte sized struct containing eight bits. I know how to
set the bits separately (struct_name.variable_name), but how do I set the
entire struct?

struct.name = 0x0a does not work!

My target platform is a tiny PIC processor, and I am using the PICC
compiler (ANSI C compliant).

Thanks!
A:
I have never used the bitfield struct construct in C. This is a feature
that is generally rarely used by programmers. Whenever I needed something
like that I rather used unsigned char and the bitwise | & and ^ operators.

I recommend that you do the same and avoid using the bitfield declaration.

regards,
Peter

[ back to toc ]