ARM Technical Support Knowledge Articles

ERROR C102 (DIFFERENT CONST/VOLATILE...) USING SBIT

Applies to: C166 C Compiler

Answer


Information in this article applies to:


SYMPTOMS

I 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?

CAUSE

This error message is generated because an sbit is not exactly the same variable type as a bit.

RESOLUTION

To 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;
}

Article last edited on: 2004-06-25 10:02:37

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential