是否仍然使用register关键字? [英] Is the register keyword still used?

查看:160
本文介绍了是否仍然使用register关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚遇到C ++中的注册关键字,我想知道这似乎是一个好主意(保持某些变量在寄存器中)肯定编译器这样做默认情况下?

Just came across the register keyword in C++ and I wondered as this seems a good idea (keeping certain variables in a register) surely the compiler does this by default?

推荐答案

大多数实现只是忽略寄存器关键字(除非它强加了语法或语义错误)。

Most implementations just ignore the register keyword (unless it imposes a syntactical or semantical error).

标准也没有说任何东西必须保存在寄存器中;只是它的一个提示,该变量将被频繁使用的实现。其使用甚至​​已过时。

The standard also doesn't say that anything must be kept in a register; merely that it's a hint to the implementation that the variable is going to be used very often. Its use is even deprecated.


7.1.1存储类说明符[dcl.stc]



3)寄存器说明符是对实现的一个提示,这样声明的变量将被大量使用。 [注意:提示可以忽略,在大多数实现中,如果变量的地址被采用,它将被忽略。此使用已弃用(请参阅D.2)。 - end note]

7.1.1 Storage class specifiers [dcl.stc]

3) A register specifier is a hint to the implementation that the variable so declared will be heavily used. [ Note: The hint can be ignored and in most implementations it will be ignored if the address of the variable is taken. This use is deprecated (see D.2). — end note ]

这篇关于是否仍然使用register关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆