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,

    You wrote,
    >Sticking to convention might have proved more helpful, e.g. only MANIFEST_CONSTANTS and ENUMS are uppercase.

    I'm not sure what you mean by "MANIFEST_CONSTANTS and ENUMS".

    I suppose that this means to use uppercase for the #defines, and lowercase for the sbits. I see now that had this style been in use in the code I was working with this morning, this discussion would not be occurring.

    This may also explain the penchant of C programmers to remove uppercase from everything else, including URLs: fear of the preprocessor! Personally, I have never gotten used to seeing lowercase hex digits, which I first saw done in the C community. I've also noticed that C programmers tend to hack DOS filenames into lowercase. For the bigger picture, I think that the standard remains English.

    Robert

Reply
  • Mark,

    You wrote,
    >Sticking to convention might have proved more helpful, e.g. only MANIFEST_CONSTANTS and ENUMS are uppercase.

    I'm not sure what you mean by "MANIFEST_CONSTANTS and ENUMS".

    I suppose that this means to use uppercase for the #defines, and lowercase for the sbits. I see now that had this style been in use in the code I was working with this morning, this discussion would not be occurring.

    This may also explain the penchant of C programmers to remove uppercase from everything else, including URLs: fear of the preprocessor! Personally, I have never gotten used to seeing lowercase hex digits, which I first saw done in the C community. I've also noticed that C programmers tend to hack DOS filenames into lowercase. For the bigger picture, I think that the standard remains English.

    Robert

Children
  • "This may also explain the penchant of C programmers to remove uppercase from everything else, including URLs: fear of the preprocessor!"

    Actually, it's more likely to be those with a UNIX background - but then 'C' and UNIX are very closely linked!

    However, some parts of the internet (including some webservers) are case-sensitive (probably mostly the UNIX bits!) - so it's not always safe to fiddle with the capitalisation of a URL, E-Mail address, etc

    "I suppose that this means to use uppercase for the #defines"

    Yes, that is the convention.

    Preprocessor definitions can behave quite differently to 'C' symbols - especially concerning side-effects etc - therefore it is particularly valuable to have your Preprocessor definitions instantly distinguishable, to help avoid the common pitfalls (see any good 'C' book)

  • I'm not sure what you mean by "MANIFEST_CONSTANTS and ENUMS".

    A manifest constant is a #define an enums are enumerated integer constants as you guessed. The uppercase I used here was to indicate that they are conventionally written in uppercase. Variables are not.

    The pre-processor does not remove uppercase and uppercase hex digits have nothing to do with manifest constants or enums. Also, we convert all filenames to lower case since some OS's are case sensitive and since certain OS's don't care it makes it easier to deal with one standard.

    I had a problem with one developer on Linux that could not build my sources which I could build fine on Windows 2000. I had included a file as #include "FooBar.h" but when the file was committed to the CVS repository it ended up as foobar.h. When the Linux compiler attempted a case sensitive match for FooBar.h it could not find it and barfed.

    I have a C coding standard a my website that I invite you to browse to see what makes me tick on this subject. Also, I have some 8051 code samples there too. Enjoy!

    http://www.embeddedfw.com

  • Sorry, but your coding convention document is marked "confidential".

  • Ignore it. It's not confidential, I'm just too lazy to remove it and reprint the PDF. Apologies.