Possible Duplicate:
Address of register variable
I know that getting address of register variable is not allowed in c . But why this code is getting compiled in c++ and not in c.
int main()
{
register int a;
printf("%u\n",&a);
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The keyword
registeris only a hint to the compiler. In fact, most compilers today ignore it as they contain advanced code to pick the best register variable candidates anyway.Whenever you take the address of a variable, it is typically placed on the stack, despite the fact that you have used the
registerkeyword.