Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Other semantics associated with the register keyword

Tags:

c++

c

msdn

The register keyword is deprecated and mostly ignored.

But this little part of its documentation on the msdn made me wonder.

The compiler does not accept user requests for register variables; [...] However, all other semantics associated with the register keyword are honored.

What are those other semantics?

like image 489
crunsher Avatar asked Jun 23 '15 15:06

crunsher


Video Answer


1 Answers

For example in C you cannot take the address of an object declared with register specifier.

void foo(void)
{
    register int a = 42;
    &a;  // constraint violation
}

Another example, you cannot use register in a file scope declaration:

register int b = 42;  // constraint violation

int main(void)
{
}
like image 128
ouah Avatar answered Sep 18 '22 01:09

ouah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!