We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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!
... from all that stamping in the floor.
Honest truth, we have more projects than time so it's often easier to ask the experts and be pointed in the right direction you were: "Read about #if... in a C book"
If you really want to be honest, then, if the specific answer to the particular issue in the first post you posted was the best response, then WHY did you come back with more #if ... issues?
If you had read the chapter on #if ..,. etc (which in most books is 3-5 pages) you would have had all these issues solved in, say, 10 minutes, instead of endless discussions in this forum.
if you have specific questions that are not, as this thread, VERY basic C then please come back.
re making the poster feel stupid. Nobody but yourself can make you feel stupid. If you are one of those that promote political correctness, get out of microcontrollers, you will find very few friends among the pros.
Erik