6
註冊關鍵字是deprecated and mostly ignored。其他與註冊關鍵字相關的語義
但是它的documentation on the msdn這個小部分讓我感到驚訝。
編譯器不接受用戶對寄存器變量的請求;但是,與寄存器關鍵字相關聯的所有其他語義都可以使用。
那些其他的語義是什麼?
註冊關鍵字是deprecated and mostly ignored。其他與註冊關鍵字相關的語義
但是它的documentation on the msdn這個小部分讓我感到驚訝。
編譯器不接受用戶對寄存器變量的請求;但是,與寄存器關鍵字相關聯的所有其他語義都可以使用。
那些其他的語義是什麼?
例如在C中,您不能獲取用register
說明符聲明的對象的地址。
void foo(void)
{
register int a = 42;
&a; // constraint violation
}
另一個例子,你不能在文件範圍內聲明中使用register
:
register int b = 42; // constraint violation
int main(void)
{
}
換句話說,雖然MSVC++消除了'register'的任何運行時的缺點,你仍然有編譯時的限制。 (不,沒有好處)。 – MSalters