pitfalls of registers variables

Started by shiva, May 21, 2012, 06:06:41 PM

Previous topic - Next topic

shiva

what  is the pitfalls of registers variables...?

CommonTater

If you mean designating a local variable as register, as in...

int register counter;


There should be no downside since it's only a suggestion for the compiler.  It will decide at compile time if it can do that or not.  Remember there are only a limited number of CPU registers available and generally it's best to let the optimizer make those decisions.




AlexN

Quote from: shiva on May 21, 2012, 06:06:41 PM
what  is the pitfalls of registers variables...?
... and AFAIK for Pelles C the keywords auto and register has the same meaning and the compiler will decide itself which variables are kept in registers.
best regards
Alex ;)

CommonTater

Thanks Alex... and FWIW, the help file says auto is the default for local variables...