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!
without any # stuff I added brackets around void foo(void);
and got errors
it is just the brackets NOT the brackets and #
You are STILL confoosing precompiler conditions and compiler conditions. Compiler conditions can (in my opinion must) use brackets, precompiler condditionals do and can not (yes there is an exception to "can not" but I will not get into that it will just confuse the issue)
Erik
So if I understand what you're saying, "if" statements need brackets if they are multiple lines long to show when a conditional statement begins and ends but, because precompiler conditionals (like "#if")have a #endif to show where they end, there is no need for brackets? I believe this is what you're saying and, if so, this makes perfect sense to me.
Is this correct or have I missed something?