Pelles C forum

C language => Beginner questions => Topic started by: shiva on May 21, 2012, 06:06:41 PM

Title: pitfalls of registers variables
Post by: shiva on May 21, 2012, 06:06:41 PM
what  is the pitfalls of registers variables...?
Title: Re: pitfalls of registers variables
Post by: CommonTater on May 21, 2012, 06:57:04 PM
If you mean designating a local variable as register, as in...
Code: [Select]
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.



Title: Re: pitfalls of registers variables
Post by: AlexN on May 21, 2012, 07:05:46 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.
Title: Re: pitfalls of registers variables
Post by: CommonTater on May 21, 2012, 07:11:33 PM
Thanks Alex... and FWIW, the help file says auto is the default for local variables...