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
  • Mark wrote,
    "A good working knowledge of ISO C would have helped you"

    Robert,
    "And your point is?..."

    It's not the compiler's job to pass comment on your style - if you write a valid language construct, the compiler should just generate the corresponding object.

    A statement like

    0x04;
    would be valid 'C'; it does nothing, so the compiler would be perfectly justified in generating no code at all for it. That's not optimisation, that's a straightforward implementation!

    If you want a review of your code, to check if what you wrote is what you meant, you need something like lint and/or peer review (or, if it's all doing your head in, just go to a pier revue!)

Reply
  • Mark wrote,
    "A good working knowledge of ISO C would have helped you"

    Robert,
    "And your point is?..."

    It's not the compiler's job to pass comment on your style - if you write a valid language construct, the compiler should just generate the corresponding object.

    A statement like

    0x04;
    would be valid 'C'; it does nothing, so the compiler would be perfectly justified in generating no code at all for it. That's not optimisation, that's a straightforward implementation!

    If you want a review of your code, to check if what you wrote is what you meant, you need something like lint and/or peer review (or, if it's all doing your head in, just go to a pier revue!)

Children
  • Andrew,

    You wrote,
    >It's not the compiler's job to pass comment on your style

    Is it the compiler's job to make my life easier? Of course. And this is a fine distinction between the preprocessor and the compiler, in more general usage the preprocessor IS (a part of) the compiler. I don't need a preprocessor/compiler to ignore the fact that I've used a duplicate label, I need it to optionally give me a warning.

    I looked for a lint utility, and it seems that the C51 lint here on the Keil website is dated 1996. What would you recommend?

    Thanks,
    Robert