I declare a variable unsigned char bdata Kde in a.c.
[in file a.c] unsigned char bdata Kde;
[in file b.c] #include <stdio.h> ..... extern unsigned char bdata Kde; sbit testbit=Kde^1; void main(void) {......}
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.
sbit MODEM_RING = P1 ^ 4; #define MODEM_RING 0x04 // ring input
Andrew, Thanks, the preprocessor listing could have exposed the problem sooner had I known about it. As far as being unable to turn off the optimizer, this seems like an undesirable idea. Why would the compiler writers have a problem with an option of NOT optimizing? I'm sure it would have saved me time earlier today. Robert
Turning off the optimizer would not have helped you at all since it did not partake in your "bug". Bypassing the C pre-processor would have yielded an error but you cannot bypass the C pre-processor. A good working knowledge of ISO C would have helped you, however.
Mark Odell writes: >Turning off the optimizer would not have helped you at all since it did not partake in your "bug". Oh, but if I had been able to turn off the optimizer I would have been able to see the constant expression that was being evaluated. This is the point as to why the optimizer was a barrier, and it seems a pointless barrier. >A good working knowledge of ISO C would have helped you, however. And your point is?...that the way it's been before is the best way? Robert
Oh, but if I had been able to turn off the optimizer I would have been able to see the constant expression that was being evaluated. I'd be pretty surprised to find any compiler that didn't remove the statement:
0x04;
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
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
View all questions in Keil forum