| |||||
Technical Support Support Resources
Product Information | C166: ERROR C102 (DIFFERENT CONST/VOLATILE...) USING SBITInformation in this article applies to:
SYMPTOMSI receive the following error message: *** ERROR C102 IN LINE 4 OF .\MAIN.C: 'mybit0': different const/volatile qualifiers when I try to declare an sbit as an external variable. For example, my MAIN.H header file is: extern bit mybit0; /* bit 0 of ibase */ and my MAIN.C file is:
#include "main.h"
int bdata ibase; /* Bit-addressable int */
sbit mybit0 = ibase ^ 0; /* bit 0 of ibase */
void main (void)
{
}
Why am I getting this error message? CAUSEThis error message is generated because an sbit is not exactly the same variable type as a bit. RESOLUTIONTo resolve this problem, you may declare the bit using the volatile attribute as shown below. extern volatile bit mybit0; /* bit 0 of ibase */ Another solution is to declare the external bit so that it is not defined at the same time as the sfr. The easiest way to do this is with a #define. For example: MAIN.H#ifndef SBITS extern bit mybit0; /* Bit 0 of ibase */ #endif MAIN.C
#define SBITS
#include "main.h"
int bdata ibase; /* Bit-addressable int */
sbit mybit0 = ibase^0;
void main (void)
{
mybit0 = 0;
}
OTHER.C
#include "main.h"
void myfunc (void)
{
mybit0 = 1;
}
Last Reviewed: Friday, June 25, 2004 | ||||
| |||||