C90 - C99:寄存器结构
“注册结构”合法吗?就海湾合作委员会的标准而言(与标准分开)?
is "register struct" legal? In terms of standards and (separated from standards) in Gcc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的。 (没有引用,根本没有禁止这一点。有一个注释假设寄存器与数组的使用是有效的,并且数组在 C 结构中是二等公民)。
Yes. (No citation, there is simply no prohibition on that. There is a note assuming that the use of register with arrays is valid, and arrays are far more second class citizen in C that structs).
是的,它是合法的,但是由于 register 只是编译器可能尝试的提示,因此实际上没有任何实现必须监听它。制作一个无法存储在寄存器分配的空间内的结构也很容易。
一旦您开始如此接近与机器相关的问题,它们在标准中的作用往往只是建议,因为硬件各不相同,因此在所有体系结构中的这个级别上不可能可靠地实现相同的事情。
Yes it is legal, however since register is only a hint to the compiler to what it might try, no implementation actually has to listen to it anyway. It is also easy to make a struct that couldnt be stored within the space allotted in registers.
Once you start to get so close to machine dependant problems their part in standards tends to be merely suggestions since hardware varies such that the same things are not reliably possible at this level in all architectures.
是的,它是有效的。
register
作为关键字并不意味着变量将保存在寄存器中。 (C基本上对此没有概念)。它只是意味着不要获取此变量的地址。Yes it is valid.
register
as a keyword just doesn't mean that the variable is to be held in a register. (C basically has no concept for this). It simply means don't take an address of this variable.