| |||||
Technical Support Support Resources
Product Information | C166: DECLARING BDATA AND SBIT VARIABLESInformation in this article applies to:
QUESTIONI'm trying to use the SBIT keyword to create a bit in a BDATA variable, but I can't seem to get the example program to work:
void main (void)
{
bdata int ibase;
sbit mybit0 = ibase ^ 0;
.
.
.
mybit0 = 1;
}
I get the following compiler messages: *** WARNING C189: 'ibase': storage class changed to 'static' *** ERROR C25: syntax error near 'sbit' How do I declare local bits? ANSWERAs stated in the C166 User's Guide, the sbit notation can be only used in combintion with global variables. This means that you need to define the variable at file level. However, you may use bit-field structures instead, since the usage of bit-field structures is not restricted. Example:
struct b {
unsigned int _0: 1;
unsigned int _1: 1;
unsigned int _2: 1;
unsigned int _3: 1;
unsigned int _4: 1;
unsigned int _5: 1;
unsigned int _6: 1;
unsigned int _7: 1;
unsigned int _8: 1;
unsigned int _9: 1;
unsigned int _10: 1;
unsigned int _11: 1;
unsigned int _12: 1;
unsigned int _13: 1;
unsigned int _14: 1;
unsigned int _15: 1;
};
void main (void) {
static struct b bdata ibase;
ibase_1 = 1;
}
MORE INFORMATION
SEE ALSOLast Reviewed: Sunday, March 12, 2006 | ||||
| |||||