How do i know if a variable is in register?

Just a quick question, if i declare a variable like this:
register int i;
As far as i know register is just a request for compiler.
So how do i know if it is really placed in cpu register?
Thanks in advice.
You don't.

What difference does it make?
Do you mean that OS decides to put a variable to register or not?
The compiler decides.

There is no programmatic way to know this. Typically you can easily figure it out by loading the
program into a debugger, running until the variable in question comes into scope, then using
the debugger to print out the contents of the variable. If the variable got optimized out (into a
register), the debugger will either complain about the symbol not being found or will outright tell
you it got optimized out.
Thank you for help
Topic archived. No new replies allowed.