版本2和3间的区别
于2006-06-20 20:09:50修订的的版本2
大小: 1386
编辑: czk
备注:
于2007-07-18 19:49:44修订的的版本3
大小: 1468
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 1: 行号 1:
## page was renamed from Functions and Program Structure/4.07 Register Variables

Navigation(slides)

4.7 Register Variables

A register declaration advises the compiler that the variable in question will be heavily used. The idea is that register variables are to be placed in machine registers, which may result in smaller and faster programs. But compilers are free to ignore the advice.

The register declaration looks like

   register int  x;
   register char c;

and so on. The register declaration can only be applied to automatic variables and to the formal parameters of a function. In this later case, it looks like

   f(register unsigned m, register long n)
   {
       register int i;
       ...
   }

In practice, there are restrictions on register variables, reflecting the realities of underlying hardware. Only a few variables in each function may be kept in registers, and only certain types are allowed. Excess register declarations are harmless, however, since the word register is ignored for excess or disallowed declarations. And it is not possible to take the address of a register variable (a topic covered in Chapter 5), regardless of whether the variable is actually placed in a register. The specific restrictions on number and types of register variables vary from machine to machine.

Navigation(siblings)

TCPL/4.07_Register_Variables (2008-02-23 15:36:27由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.