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!
No, that's not true.
If the preprocessor directives, after preprocessing, leave any syntax error, then you'll get diagnostics about those errors.
In this case, the preprocessor directives, after preprocessing, left misplaced braces - so the OP got diagnostics about those misplaced braces.
It's not that the braces in any way "interfered with" or "screwed-up" the preprocessor directives.