Keil Logo

C51: Declaring External sbit Variables


Information in this article applies to:

  • C51

SYMPTOMS

I have declared an sbit called foo in a source file called bar.c:

bdata char dummy ;
sbit foo = dummy ^ 3 ;

In another source file, I have tried to declare the sbit as extern:

extern sbit foo;

However, when compiling I get a syntax error. What am I doing wrong?

RESOLUTION

When declaring an sbit as extern, you must use the 'bit' type. For example:

extern bit foo;

Note: this only works for sbit variables in the bit-addressable memory range 0x20 - 0x3F and not for SFRs declared with sbit.

MORE INFORMATION


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.