Hello. I am trying to find new and exciting ways to optimize (read: shrink down) my current code and want to include an eeprom autorefresh option to cut down on variables. Basically, when I have the AutoRefreshCompile option set, I want it to create the variable "randomvariable". My code is pretty simple:
#define AutoRefreshCompile 1 #if(AutoRefreshCompile==1) { // line x extern signed short randomvariable; } // line y #endif
I am getting errors that read as follows:
VARS.H(x) error C141: syntax error near '{' VARS.H(y) error C141: syntax error near '}'
I'm guessing it is not possible to do this (if I remember correctly, variables have to be declared at the beginning and can't be in the middle of functions/code segments but maybe it's some really simple fix.
I realize this might not work but I figure it's worth a shot. Any suggestions? Thanks!
For the record, if you (or anyone else, really) had told me a few posts ago that my fundamental understanding was in directives vs statements rather than telling me to go find a C book and start reading, it could've saved us all a lot of time. Generic recommendations like "read a book" aren't anywhere near as helpful as saying "you need to read a book about the difference between directives and statements".
Utter nonsense. You would have saved a lot more time if you had actually properly read a C book. As Andrew said, K&R is only 160 pages. Curly brackets and statements is fundamental stuff. It's rather obvious that you are not into reading books. Apparently, you prefer to dive into coding and sort out problems through forums. That's OK, but don't expect much sympathy from people who gained knowledge the old-fashioned way. And may I say, your way of learning is rather inefficient.
Actually, I said the tutorial part is only about 160 pages - in addition to that, you get another ~110 pages of reference.
For reference, I prefer to use the standard.
www.open-std.org/.../n1124.pdf
Yes, it's a draft of C99. Should be good enough for most needs anyway.
But note that C99 allows declarations anywhere within a block - not just at the start.
I don't think C51 allows this?
http://www.keil.com/product/isoansi.asp
Trying to use C99 features in pre-C99 compilers (like C51) is a not-infrequent source of problems on forums like this...
http://www.keil.com/support/man/docs/c51/c51_xa.htm
It's people like you I don't get. This forum already has plenty of people who add nothing to a technical discussion and only seem to pop in to berate someone for their approach on a subject or their lack of knowledge. Add something to the conversation or go away. There are already too many of you.
That entire last paragraph was unnecessary. You could have just as easily stated your concerns in the way Neil did without judgemental statements but you had to go that extra mile to be an ***.
And you don't know anything about me or my approach.
Add something to the conversation or go away
what about your last posts that are nothingn but WAAAAAAAAHH. how muct do they "Add to the conversation"
Erik
you had to go that extra mile to be an ***
Agressive ignorance. How charming.
Agressive ignorance. How charming. typical response from someone that expect the replies to be "politically corect"
I have seen this many times "why did you not answer the way I wanted you to, expletive"
it is amazing that the more someone expect others to be "politically correct" the more likely it is that the reply to whatever is not seen as "politically correct" will be an expletive