Other semantics associated with the register keyword

142 views Asked by At

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?

1

There are 1 answers

1
ouah On BEST ANSWER

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)
{
}