using registers in a for loop

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?

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 }
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.