This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to use extern sbit declare?

I declare a variable unsigned char bdata Kde in a.c.

[in file a.c]

unsigned char bdata Kde;

Than I want to use the variable inb.c.
[in file b.c]
#include <stdio.h>
.....
extern unsigned char bdata Kde;
sbit testbit=Kde^1;
void main(void)
{......}

:error C141:.......a.c:syntax error near 'sbit'

why?

Parents
  • Cuthbert,

    I see that your problem is documented and discussed on page 378 of the C51 User's Guide, User's Guide 09.2001.

    ...maybe it is not coincidence that I was reading that page earlier today.

    However, it turned out that my problem was that my sbit was being redefined and the compiler gave no warning, then optimized away all of the references to the sbit.

    sbit MODEM_RING = P1 ^ 4;
    #define MODEM_RING 0x04 // ring input

    My question is, why was there no warning?

    Another question, how do I turn off the optimizer? I tried setting it to zero but the code was still removed.

Reply
  • Cuthbert,

    I see that your problem is documented and discussed on page 378 of the C51 User's Guide, User's Guide 09.2001.

    ...maybe it is not coincidence that I was reading that page earlier today.

    However, it turned out that my problem was that my sbit was being redefined and the compiler gave no warning, then optimized away all of the references to the sbit.

    sbit MODEM_RING = P1 ^ 4;
    #define MODEM_RING 0x04 // ring input

    My question is, why was there no warning?

    Another question, how do I turn off the optimizer? I tried setting it to zero but the code was still removed.

Children