Should I use the register keyword on my phone variable not? I have this:
void *anything(Caller *caller)
{
register void *phone = caller->phone;
/* or this */
void *phone = caller->phone;
if (phone)
{
return phone;
}
return NULL;
}
Is there a difference? What should I do?
The
registerkeyword was intended as an optimization hint to the compiler. The problem is, the compiler knows your code better than you do, and these days do not need such simplistic hints to generate better code.So the only thing
registerdoes with modern compilers is prevent you from using&to take the address of the variable. That’s it.