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!
going by the number and frequency of posts it look like work is light for a certain regular poster at the moment.
eg, http://www.keil.com/forum/21544/
Well, I guess you could use some sort of compression; but it seems rather unlikely that the overhead of the compression & decompression software would leave any net benefit - especially on an 8051.
Plus there'd be the speed penalty.
Or both.
I want it to create the variable "randomvariable"
And you are using extern for that? Either you are not telling the whole story, or you are very confused.
And what, exactly, do you mean by that?
Remember that optimisation happens at compile time - you can't retrospectively optimise at run time!
"I'm guessing..."
Don't guess!!
If you want to out-smart the compiler, then you're going to need a really thorough understanding of not just the 'C' language, but also compiler technology.
Here are some 'C' references for you to study: blog.antronics.co.uk/.../12
Please stop mixing C-preprocessor directives and normal C statements. This is not the first question of yours doing so. Get some books about using C and don't try to be 'more clever' than other C developers by writing obscure things.
View all questions in Keil forum