简体   繁体   English

C90 - C99:注册结构

[英]C90 - C99: register struct

is "register struct" legal? 是“注册结构”合法吗? In terms of standards and (separated from standards) in Gcc? 在Gcc的标准和(与标准分开)方面?

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). (没有引用,根本就没有禁止。有一个注释假设使用带数组的寄存器是有效的,并且数组在C结构中是更多的二等公民)。

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. 一旦你开始如此接近机器相关问题,他们在标准中的部分往往只是建议,因为硬件变化使得在所有体系结构中在这个级别上不可能完全相同的事情。

Yes it is valid. 是的,它是有效的。

register as a keyword just doesn't mean that the variable is to be held in a register. register为关键字并不意味着变量将保存在寄存器中。 (C basically has no concept for this). (C基本上没有这个概念)。 It simply means don't take an address of this variable . 它只是意味着不要获取此变量的地址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM