was tagged [tech] 2009/7/21 Justin Richards > In C18 a union can be described as follows > > typedef union _IP_ADDR > { > BYTE v[4]; > DWORD Val; > } IP_ADDR; > > > Then memory may be referenced as follows [after a variable IP of type > IP_ADDR is declared] > i=3; > IP.v[i]; > > Can a similar member reference be used with bits. > > That is instead of referencing a bit member in the union below as > > iomask.bits.b0; > > Can it be referenced as > > iomask.bits[i]; or perhaps iomask.bits.b[i]; > > Experimenting with the compiler seems to indicate that it is not possible. > > Pointers to examples etc would be greatly appreciated or even what to > google for. > > union > { > struct > { > unsigned char b0:1; > unsigned char b1:1; > unsigned char b2:1; > unsigned char b3:1; > unsigned char b4:1; > unsigned char b5:1; > unsigned char b6:1; > unsigned char b7:1; > } bits; > BYTE val; > } iomask; > > Cheers Justin > > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist