Register Variables in c

David Brown david@westcontrol.com
Fri Sep 19 11:18:00 GMT 2014


On 19/09/14 00:56, Ian Lance Taylor wrote:
> On Thu, Sep 18, 2014 at 2:15 AM, Ali Abdul Ghani <blade.vp2020@gmail.com> wrote:
>>
>> I have a question
>> I read about register variables
>> gcc Support register variables??
>>
>> or treat him like any other variable??
> 
> In GCC the only meanings of the register qualifier are that you can't
> the address of a register variable, and as a GCC extension you can
> declare the specific register that the variable should go into.
> 

I believe the register qualifier is used as a hint when you compile
without optimisation, and will encourage the compiler to put the
variable in a register rather than on the stack.  The hint is ignored
when optimising - they are treated as any other variable (other than
making it illegal to take an address), as the compiler will do a better
job of allocating variables to registers than a human would.

David




More information about the Gcc-help mailing list