|
|
1.1 root 1:
2:
3: register variable Definition register variable
4:
5:
6:
7:
8: register is a C storage class. A register declaration tells the
9: compiler to try to keep the defined local data item in a machine
10: register. Under the COHERENT C compiler, the iinntt ffoooo can be
11: declared to be a register variable with the following statement:
12:
13:
14: register int foo;
15:
16:
17: COHERENT places the first two register variables declared in a
18: function into registers SI and DI if the variable type is ap-
19: propriate, i.e., int or SMALL-model pointer. Subsequent register
20: declarations are ignored, because no registers are left to hold
21: them. Note because of this fact, declaring more than two
22: register variables may slow processing rather than speed it.
23:
24: By definition of the C language, registers have no addresses, so
25: you cannot pass the address of register variable as an argument
26: to a function. For example, the following code will generate an
27: error message when compiled:
28:
29:
30: register int i;
31: . . .
32: dosomething(&i); /* WRONG */
33:
34:
35: This rule applies whether or not the variable is actually kept in
36: a register.
37:
38: Placing heavily-used local variables into registers often im-
39: proves performance, but in some cases declaring register
40: variables can degrade performance somewhat.
41:
42: ***** See Also *****
43:
44: auto, definitions, extern, static, storage class
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.