tags:

views:

73

answers:

3

Hello

is "register struct" legal? In terms of standards and (separated from standards) in Gcc?

+1  A: 

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).

AProgrammer
+2  A: 

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.

Fish
+1  A: 

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.

Jens Gustedt