using registers in a for loop

Apr 15, 2008 at 10:13pm
I'm trying to recall how to use a register to increment a for loop... this is an old C thing that I was taught back in the 80's.. If I recall it went something like..

for(reg i=0 ; i<something ; i++) { do something }

Is that it? Any help here?
Apr 15, 2008 at 11:37pm

Declare int using 'register' keyword. This tells the compiler to store the variable being declared in a CPU register.

example:

for(register int i=0 ; i<something ; i++) { do something }
Apr 16, 2008 at 6:48am
You shouldn't try to second guess the compiler's decisions on how to optimize the code. If using a register is good for performance, the compiler will probably use a register.
Topic archived. No new replies allowed.