|
|
1.1 root 1:
2:
3: portability Technical Information portability
4:
5:
6:
7:
8: Portability means that code can be recompiled and run under dif-
9: ferent computing environments without modification. Although
10: true portability is an ideal that is difficult to realize, you
11: can take a number of practical steps to ensure that your code is
12: portable:
13:
14: 11.
15: Do not assume that an integer and a pointer have the same
16: size. Remember that undeclared functions are assumed to
17: return an int. If a function returns a pointer, declare it
18: so.
19:
20: 22.
21: Do not write routines that depend on a particular order of
22: code evaluation, particular byte ordering, or particular
23: length of data types.
24:
25: 33.
26: Do not write routines that play tricks with a machine's
27: ``magic characters''; for example, writing a routine that
28: depends on a file's ending with <ccttrrll-ZZ> instead of EEOOFF en-
29: sures that that code can run only under operating systems
30: that recognize this magic character.
31:
32: 44.
33: Always use manifest constants, such as EEOOFF, and make full
34: use of #ddeeffiinnee statements.
35:
36: 55.
37: Use header files to hold all machine-dependent declarations
38: and definitions.
39:
40: 66.
41: Declare everything explicitly. In particular, be sure to
42: declare functions as vvooiidd if they do not return a value;
43: this avoids unforeseen problems with undefined return
44: values.
45:
46: 77.
47: Do not assume that integers and pointers have the same size
48: or even the same kind of structure. Do not assume that
49: pointers are all the same or can point anywhere. On the
50: i8086, in SMALL model a pointer to a function addresses
51: relative to the code segment, whereas a pointer to data ad-
52: dresses relative to the data segment. On some machines,
53: character pointers are of a different size or structure than
54: word pointers.
55:
56: 88.
57: The constant NULL is defined as being different from any
58: valid pointer. Use it and nothing else for that purpose.
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
67:
68:
69: portability Technical Information portability
70:
71:
72:
73: ***** See Also *****
74:
75: header file, pointer, technical information, void
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130: COHERENT Lexicon Page 2
131:
132:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.