NO

Author Topic: pitfalls of registers variables  (Read 2849 times)

shiva

  • Guest
pitfalls of registers variables
« on: May 21, 2012, 06:06:41 PM »
what  is the pitfalls of registers variables...?

CommonTater

  • Guest
Re: pitfalls of registers variables
« Reply #1 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.




Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: pitfalls of registers variables
« Reply #2 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.
best regards
 Alex ;)

CommonTater

  • Guest
Re: pitfalls of registers variables
« Reply #3 on: May 21, 2012, 07:11:33 PM »
Thanks Alex... and FWIW, the help file says auto is the default for local variables...