|
|
1.1 root 1: .\" @(#)Clang.ms 6.2 (Berkeley) 5/27/86
2: .\"
3: .nr Cl 2
4: .TL
5: The C Programming Language - Reference Manual
6: .AU
7: Dennis M. Ritchie
8: .AI
9: .MH
10: .PP
11: This manual is a reprint, with updates to the current C standard, from
12: \fIThe C Programming Language\fR,
13: by Brian W. Kernighan and Dennis M. Richie, Prentice-Hall, Inc., 1978.
14: .EH 'PS1:1-%''The C Programming Language - Reference Manual'
15: .OH 'The C Programming Language - Reference Manual''PS1:1-%'
16: .NH 1
17: Introduction
18: .PP
19: This manual describes the C language on the DEC PDP-11\(dg, the DEC VAX-11,
20: .FS
21: .LP
22: \(dg DEC PDP-11, and DEC VAX-11 are trademarks of Digital Equipment Corporation.
23: .LP
24: \(dd 3B 20 is a trademark of AT&T.
25: .FE
26: and the AT&T 3B 20\(dd.
27: Where differences exist, it concentrates on the VAX, but tries to point
28: out implementation-dependent details. With few execptions, these dependencies
29: follow directly from the underlying properties of the hardware; the various
30: compilers are generally quite compatible.
31: .NH 1
32: Lexical Conventions
33: .PP
34: There are six classes of tokens\ -\
35: identifiers, keywords, constants, strings, operators, and other separators.
36: Blanks, tabs, new\(hylines,
37: and comments (collectively, ``white space'') as described below
38: are ignored except as they serve to separate
39: tokens.
40: Some white space is required to separate
41: otherwise adjacent identifiers,
42: keywords, and constants.
43: .PP
44: If the input stream has been parsed into tokens
45: up to a given character, the next token is taken
46: to include the longest string of characters
47: which could possibly constitute a token.
48: .NH 2
49: Comments
50: .PP
51: The characters
52: .B
53: /*
54: .R
55: introduce a comment which terminates
56: with the characters
57: \fB\(**/\fR.
58: Comments do not nest.
59: .NH 2
60: Identifiers (Names)
61: .PP
62: An identifier is a sequence of letters and digits.
63: The first character must be a letter.
64: The underscore
65: (\fB_\fR)
66: counts as a letter.
67: Uppercase and lowercase letters
68: are different.
69: Although there is no limit on the length of a name,
70: only initial characters are significant: at least
71: eight characters of a non-external name, and perhaps
72: fewer for external names.
73: Moreover, some implementations may collapse case
74: distinctions for external names.
75: The external name sizes include:
76: .DS
77: .TS
78: l l.
79: PDP-11 7 characters, 2 cases
80: VAX-11 >100 characters, 2 cases
81: AT&T 3B 20 >100 characters, 2 cases
82: .TE
83: .fi
84: .DE
85: .NH 2
86: Keywords
87: .PP
88: The following identifiers are reserved for use
89: as keywords and may not be used otherwise:
90: .DS
91: .ta 0.8i 1.6i 2.4i 3.2i 4.0i
92: \fBauto do for return typedef
93: break double goto short union
94: case else if sizeof unsigned
95: char enum int static void
96: continue external long struct while
97: default float register switch\fR
98: .ta 0.5i
99: .DE
100: .PP
101: Some implementations also reserve the words
102: .B
103: fortran, asm, gfloat, hfloat
104: .R
105: and
106: .B quad
107: .R
108: .NH 2
109: Constants
110: .PP
111: There are several kinds
112: of constants.
113: Each has a type; an introduction to types is given in ``NAMES.''
114: Hardware characteristics that affect sizes are summarized in
115: ``Hardware Characteristics'' under ``LEXICAL CONVENTIONS.''
116: .NH 3
117: Integer Constants
118: .br
119: .PP
120: An integer constant consisting of a sequence of digits
121: is taken
122: to be octal if it begins with
123: .B
124: 0
125: .R
126: (digit zero).
127: An octal constant consists of the digits \fB0\fR through \fB7\fR only.
128: A sequence of digits preceded by
129: .B
130: 0x
131: .R
132: or
133: .B
134: 0X
135: .R
136: (digit zero) is taken to be a hexadecimal integer.
137: The hexadecimal digits include
138: .B
139: a
140: .R
141: or
142: .B
143: A
144: .R
145: through
146: .B
147: f
148: .R
149: or
150: .B
151: F
152: .R
153: with values 10 through 15.
154: Otherwise, the integer constant is taken to be decimal.
155: A decimal constant whose value exceeds the largest
156: signed machine integer is taken to be
157: \fBlong\fR;
158: an octal or hex constant which exceeds the largest unsigned machine integer
159: is likewise taken to be
160: .B
161: long\fR.
162: .R
163: Otherwise, integer constants are \fBint\fR.
164: .NH 3
165: Explicit Long Constants
166: .br
167: .PP
168: A decimal, octal, or hexadecimal integer constant immediately followed
169: by
170: .B
171: l
172: .R
173: (letter ell)
174: or
175: .B
176: L
177: .R
178: is a long constant.
179: As discussed below,
180: on some machines
181: integer and long values may be considered identical.
182: .NH 3
183: Character Constants
184: .br
185: .PP
186: A character constant is a character enclosed in single quotes,
187: as in '\fBx\fR'.
188: The value of a character constant is the numerical value of the
189: character in the machine's character set.
190: .PP
191: Certain nongraphic characters,
192: the single quote
193: (\fB'\fR)
194: and the backslash
195: (\fB\e\fR),
196: may be represented according to the following table
197: of escape sequences:
198: .DS
199: .TS
200: l l l.
201: new\(hyline NL (LF) \en
202: horizontal tab HT \et
203: vertical tab VT \ev
204: backspace BS \eb
205: carriage return CR \er
206: form feed FF \ef
207: backslash \e \e\e
208: single quote ' \e'
209: bit pattern \fIddd\fR\^ \e\fIddd\fR\^
210: .TE
211: .DE
212: .PP
213: The escape
214: \e\fIddd\fR
215: consists of the backslash followed by 1, 2, or 3 octal digits
216: which are taken to specify the value of the
217: desired character.
218: A special case of this construction is
219: .B
220: \e0
221: .R
222: (not followed
223: by a digit), which indicates the character
224: .B
225: NUL\fR.
226: .R
227: If the character following a backslash is not one
228: of those specified, the
229: behavior is undefined.
230: A new-line character is illegal in a character constant.
231: The type of a character constant is \fBint\fR.
232: .NH 3
233: Floating Constants
234: .br
235: .PP
236: A floating constant consists of
237: an integer part, a decimal point, a fraction part,
238: an
239: .B
240: e
241: .R
242: or
243: \fBE\fR,
244: and an optionally signed integer exponent.
245: The integer and fraction parts both consist of a sequence
246: of digits.
247: Either the integer part or the fraction
248: part (not both) may be missing.
249: Either the decimal point or
250: the
251: .B
252: e
253: .R
254: and the exponent (not both) may be missing.
255: Every floating constant has type \fBdouble\fR.
256: .NH 3
257: Enumeration Constants
258: .br
259: .PP
260: Names declared as enumerators
261: (see ``Structure, Union, and Enumeration Declarations'' under
262: ``DECLARATIONS'')
263: have type \fBint\fR.
264: .NH 2
265: Strings
266: .PP
267: A string is a sequence of characters surrounded by
268: double quotes,
269: as in
270: \fB"..."\fR.
271: A string has type
272: ``array of \fBchar\fR'' and storage class
273: \fBstatic\fR
274: (see ``NAMES'')
275: and is initialized with
276: the given characters.
277: The compiler places
278: a null byte
279: (\fB\e0\fR)
280: at the end of each string so that programs
281: which scan the string can
282: find its end.
283: In a string, the double quote character
284: (\fB"\fR)
285: must be preceded by
286: a
287: \fB\e\fR;
288: in addition, the same escapes as described for character
289: constants may be used.
290: .PP
291: A
292: .B
293: \e
294: .R
295: and
296: the immediately following new\(hyline are ignored.
297: All strings, even when written identically, are distinct.
298: .NH 2
299: Hardware Characteristics
300: .PP
301: The following figure summarize
302: certain hardware properties that vary from machine to machine.
303: .DS
304: .TS
305: center box;
306: c cfB s cfB s cfB s
307: c c s c s c s
308: l | l1 lp8 | l1 lp8 | l1 lp8.
309: DEC PDP\-11 DEC VAX-11 AT&T 3B
310: (ASCII) (ASCII) (ASCII)
311: .sp
312: _
313: char 8 bits 8 bits 8bits
314: int 16 32 32
315: short 16 16 16
316: long 32 32 32
317: float 32 32 32
318: double 64 64 64
319: float range \(+-10 \(+-38 \(+-10 \(+-38 \(+-10 \(+-38
320: \^ \^ \^ \^
321: double range \(+-10 \(+-38 \(+-10 \(+-38 \(+-10 \(+-308
322: \^ \^ \^ \^
323: .TE
324: .FG 4 4 1 "DEC PDP-11 HARDWARE CHARACTERISTICS"
325: .DE
326: .PP
327: .NH 1
328: Syntax Notation
329: .PP
330: Syntactic categories are indicated by
331: .I
332: italic
333: .R
334: type
335: and literal words and characters
336: in
337: \fBbold\fR
338: type.
339: Alternative categories are listed on separate lines.
340: An optional terminal or nonterminal symbol is
341: indicated by the subscript ``opt,'' so that
342: .DS
343: { \fIexpression\v'0.5'\s-2opt\s0\v'-0.5'\fR }
344: .DE
345: .LP
346: indicates an optional expression enclosed in braces.
347: The syntax is summarized in ``SYNTAX SUMMARY''.
348: .NH 1
349: Names
350: .PP
351: The C language bases the interpretation of an
352: identifier upon two attributes of the identifier \(mi its
353: .I
354: storage class
355: .R
356: and its
357: .I
358: type\fR.
359: The storage class determines the location and lifetime
360: of the storage associated with an identifier;
361: the type determines
362: the meaning of the values
363: found in the identifier's storage.
364: .NH 2
365: Storage Class
366: .PP
367: There are four declarable storage classes:
368: .BL 6 1
369: .LI
370: Automatic
371: .LI
372: Static
373: .LI
374: External
375: .LI
376: Register.
377: .LE
378: .PP
379: Automatic variables are local to each invocation of
380: a block (see ``Compound Statement or Block'' in
381: ``STATEMENTS'') and are discarded upon exit from the block.
382: Static variables are local to a block but retain
383: their values upon reentry to a block even after control
384: has left the block.
385: External variables exist and retain their values throughout
386: the execution of the entire program and
387: may be used for communication between
388: functions, even separately compiled functions.
389: Register variables are (if possible) stored in the fast registers
390: of the machine; like automatic
391: variables, they are local to each block and disappear on exit from the block.
392: .NH 2
393: Type
394: .PP
395: The C language supports several
396: fundamental
397: types of objects.
398: Objects declared as characters
399: (\fBchar\fR)
400: are large enough to store any member of the implementation's
401: character set.
402: If a genuine character from that character set is
403: stored in a \fBchar\fR variable,
404: its value is equivalent to the integer code for that character.
405: Other quantities may be stored into character variables, but
406: the implementation is machine dependent.
407: In particular, \fBchar\fR may be signed or unsigned by default.
408: .PP
409: Up to three sizes of integer, declared
410: .B
411: short
412: .R
413: \fBint\fR,
414: \fBint\fR,
415: and
416: .B
417: long
418: .R
419: \fBint\fR,
420: are available.
421: Longer integers provide no less storage than shorter ones,
422: but the implementation may make either short integers or long integers,
423: or both, equivalent to plain integers.
424: ``Plain'' integers have the natural size suggested
425: by the host machine architecture.
426: The other sizes are provided to meet special needs.
427: .PP
428: The properties of \fBenum\fR types (see ``Structure, Union, and Enumeration Declarations''
429: under ``DECLARATIONS'')
430: are identical to those of
431: some integer types.
432: The implementation may use the range of values to
433: determine how to allocate storage.
434: .PP
435: Unsigned
436: integers, declared
437: .B
438: unsigned,
439: .R
440: obey the laws of arithmetic modulo
441: 2\v'-0.5'\fIn\fR\v'0.5'
442: where \fIn\fR is the number of bits in the representation.
443: (On the
444: PDP-11,
445: unsigned long quantities are not supported.)
446: .PP
447: Single-precision floating point
448: (\fBfloat\fR)
449: and double precision floating point
450: (\fBdouble\fR)
451: may be synonymous in some implementations.
452: .PP
453: Because objects of the foregoing types can usefully be interpreted
454: as numbers, they will be referred to as
455: .I
456: arithmetic
457: .R
458: types.
459: \fBChar\fR,
460: .B
461: int
462: .R
463: of all sizes whether \fBunsigned\fR or not, and
464: .B
465: enum
466: .R
467: will collectively be called
468: .I
469: integral
470: .R
471: types.
472: The
473: .B
474: float
475: .R
476: and
477: .B
478: double
479: .R
480: types will collectively be called
481: .I
482: floating
483: .R
484: types.
485: .PP
486: The
487: .B
488: void
489: .R
490: type
491: specifies an empty set of values.
492: It is used as the type returned by functions that
493: generate no value.
494: .PP
495: Besides the fundamental arithmetic types, there is a
496: conceptually infinite class of derived types constructed
497: from the fundamental types in the following ways:
498: .BL 6 1
499: .LI
500: \fIArrays\fR
501: of objects of most types
502: .LI
503: \fIFunctions\fR
504: which return objects of a given type
505: .LI
506: \fIPointers\fR
507: to objects of a given type
508: .LI
509: \fIStructures\fR
510: containing a sequence of objects of various types
511: .LI
512: \fIUnions\fR
513: capable of containing any one of several objects of various types.
514: .LE
515: .PP
516: In general these methods
517: of constructing objects can
518: be applied recursively.
519: .NH 1
520: Objects and Lvalues
521: .PP
522: An
523: .I
524: object
525: .R
526: is a manipulatable region of storage.
527: An
528: .I
529: lvalue
530: .R
531: is an expression referring to an object.
532: An obvious example of an lvalue
533: expression is an identifier.
534: There are operators which yield lvalues:
535: for example,
536: if
537: .B
538: E
539: .R
540: is an expression of pointer type, then
541: .B
542: \(**E
543: .R
544: is an lvalue
545: expression referring to the object to which
546: .B
547: E
548: .R
549: points.
550: The name ``lvalue'' comes from the assignment expression
551: .B
552: E1\ =\ E2
553: .R
554: in which the left operand
555: .B
556: E1
557: .R
558: must be
559: an lvalue expression.
560: The discussion of each operator
561: below indicates whether it expects lvalue operands and whether it
562: yields an lvalue.
563: .NH 1
564: Conversions
565: .PP
566: A number of operators may, depending on their operands,
567: cause conversion of the value of an operand from one type to another.
568: This part explains the result to be expected from such
569: conversions.
570: The conversions demanded by most ordinary operators are summarized under
571: ``Arithmetic Conversions.''
572: The summary will be supplemented
573: as required by the discussion
574: of each operator.
575: .NH 2
576: Characters and Integers
577: .PP
578: A character or a short integer may be used wherever an
579: integer may be used.
580: In all cases
581: the value is converted to an integer.
582: Conversion of a shorter integer
583: to a longer preserves sign.
584: Whether or not sign-extension occurs for characters is machine
585: dependent, but it is guaranteed that a member of the
586: standard character set is non-negative.
587: Of the machines treated here,
588: only the
589: PDP-11
590: and
591: VAX-11
592: sign-extend.
593: On these machines,
594: .B
595: char
596: .R
597: variables range in value from
598: \(mi128 to 127.
599: The more explicit type
600: .B
601: unsigned
602: .R
603: .B
604: char
605: .R
606: forces the values to range from 0 to 255.
607: .PP
608: On machines that treat characters as signed,
609: the characters of the
610: ASCII
611: set are all non-negative.
612: However, a character constant specified
613: with an octal escape suffers sign extension
614: and may appear negative;
615: for example,
616: \fB\'\e377\'\fR
617: \fRhas the value
618: .B
619: \(mi1\fR.
620: .PP
621: When a longer integer is converted to a shorter
622: integer
623: or to a
624: .B
625: char,
626: .R
627: it is truncated on the left.
628: Excess bits are simply discarded.
629: .NH 2
630: Float and Double
631: .PP
632: All floating arithmetic in C is carried out in double precision.
633: Whenever a
634: .B
635: float
636: .R
637: appears in an expression it is lengthened to
638: .B
639: double
640: .R
641: by zero padding its fraction.
642: When a
643: .B
644: double
645: .R
646: must be
647: converted to
648: \fBfloat\fR,
649: for example by an assignment,
650: the
651: .B
652: double
653: .R
654: is rounded before
655: truncation to
656: .B
657: float
658: .R
659: length.
660: This result is undefined if it cannot be represented as a float.
661: On the VAX, the compiler can be directed to use single percision for expressions
662: containing only float and interger operands.
663: .NH 2
664: Floating and Integral
665: .PP
666: Conversions of floating values to integral type
667: are rather machine dependent.
668: In particular, the direction of truncation of negative numbers
669: varies.
670: The result is undefined if
671: it will not fit in the space provided.
672: .PP
673: Conversions of integral values to floating type
674: are well behaved.
675: Some loss of accuracy occurs
676: if the destination lacks sufficient bits.
677: .NH 2
678: Pointers and Integers
679: .PP
680: An expression of integral type may be added to or subtracted from
681: a pointer; in such a case,
682: the first is converted as
683: specified in the discussion of the addition operator.
684: Two pointers to objects of the same type may be subtracted;
685: in this case, the result is converted to an integer
686: as specified in the discussion of the subtraction
687: operator.
688: .NH 2
689: Unsigned
690: .PP
691: Whenever an unsigned integer and a plain integer
692: are combined, the plain integer is converted to unsigned
693: and the result is unsigned.
694: The value
695: is the least unsigned integer congruent to the signed
696: integer (modulo 2\v'-0.3'\s-2wordsize\s+2\v'0.3').
697: In a 2's complement representation,
698: this conversion is conceptual; and there is no actual change in the
699: bit pattern.
700: .PP
701: When an unsigned \fBshort\fR integer is converted to
702: \fBlong\fR,
703: the value of the result is the same numerically as that of the
704: unsigned integer.
705: Thus the conversion amounts to padding with zeros on the left.
706: .NH 2
707: Arithmetic Conversions
708: .PP
709: A great many operators cause conversions
710: and yield result types in a similar way.
711: This pattern will be called the ``usual arithmetic conversions.''
712: .AL 1 6
713: .LI
714: First, any operands of type
715: .B
716: char
717: .R
718: or
719: .B
720: short
721: .R
722: are converted to
723: \fBint\fR,
724: and any operands of type \fBunsigned char\fR
725: or \fBunsigned short\fR are converted
726: to \fBunsigned int\fR.
727: .LI
728: Then, if either operand is
729: .B
730: double,
731: .R
732: the other is converted to
733: .B
734: double
735: .R
736: and that is the type of the result.
737: .LI
738: Otherwise, if either operand is \fBunsigned long\fR,
739: the other is converted to \fBunsigned long\fR and that
740: is the type of the result.
741: .LI
742: Otherwise, if either operand is
743: \fBlong\fR,
744: the other is converted to
745: .B
746: long
747: .R
748: and that is the type of the result.
749: .LI
750: Otherwise, if one operand is \fBlong\fR, and
751: the other is \fBunsigned int\fR, they are both
752: converted to \fBunsigned long\fR and that is
753: the type of the result.
754: .LI
755: Otherwise, if either operand is
756: .B
757: unsigned,
758: .R
759: the other is converted to
760: .B
761: unsigned
762: .R
763: and that is the type of the result.
764: .LI
765: Otherwise, both operands must be
766: \fBint\fR,
767: and that is the type of the result.
768: .LE
769: .NH 2
770: Void
771: .PP
772: The (nonexistent) value of a
773: .B
774: void
775: .R
776: object may not be used in any way,
777: and neither explicit nor implicit conversion may be applied.
778: Because a void expression denotes a nonexistent value,
779: such an expression may be used only
780: as an expression statement
781: (see ``Expression Statement'' under ``STATEMENTS'')
782: or as the left operand
783: of a comma expression (see ``Comma Operator'' under ``EXPRESSIONS'').
784: .PP
785: An expression may be converted to
786: type
787: .B
788: void
789: .R
790: by use of a cast.
791: For example, this makes explicit the discarding of the value
792: of a function call used as an expression statement.
793: .NH 1
794: Expressions
795: .PP
796: The precedence of expression operators is the same
797: as the order of the major
798: subsections of this section, highest precedence first.
799: Thus, for example, the expressions referred to as the operands of
800: .B
801: \(pl
802: .R
803: (see ``Additive Operators'')
804: are those expressions defined under ``Primary Expressions'',
805: ``Unary Operators'', and ``Multiplicative Operators''.
806: Within each subpart, the operators have the same
807: precedence.
808: Left- or right-associativity is specified
809: in each subsection for the operators
810: discussed therein.
811: The precedence and associativity of all the expression
812: operators are summarized in the
813: grammar of ``SYNTAX SUMMARY''.
814: .PP
815: Otherwise, the order of evaluation of expressions
816: is undefined. In particular, the compiler
817: considers itself free to
818: compute subexpressions in the order it believes
819: most efficient
820: even if the subexpressions
821: involve side effects.
822: The order in which subexpression evaluation takes place is unspecified.
823: Expressions involving a commutative and associative
824: operator
825: (\fB\(**,\fR
826: \fB\(pl\fR,
827: \fB&\fR,
828: \fB|\fR,
829: \fB^\fR)
830: may be rearranged arbitrarily even in the presence
831: of parentheses;
832: to force a particular order of evaluation,
833: an explicit temporary must be used.
834: .PP
835: The handling of overflow and divide check
836: in expression evaluation
837: is undefined.
838: Most existing implementations of C ignore integer overflows;
839: treatment of
840: division by 0 and all floating-point exceptions
841: varies between machines and is usually
842: adjustable by a library function.
843: .NH 2
844: Primary Expressions
845: .PP
846: Primary expressions
847: involving \fB\.\fR,
848: \fB\(mi>\fR,
849: subscripting, and function calls
850: group left to right.
851: .DS
852: \fIprimary-expression:
853: identifier
854: constant
855: string
856: ( expression )
857: primary-expression [ expression ]
858: primary-expression ( expression-list\v'0.5'\s-2opt\s0\v'-0.5' )
859: primary-expression . identifier
860: primary-expression \(mi> identifier\fR
861: .DE
862: .DS
863: \fIexpression-list:
864: expression
865: expression-list , expression\fR
866: .DE
867: .PP
868: An identifier is a primary expression provided it has been
869: suitably declared as discussed below.
870: Its type is specified by its declaration.
871: If the type of the identifier is ``array of .\|.\|.'',
872: then the value of the identifier expression
873: is a pointer
874: to the first object in the array; and the
875: type of the expression is
876: ``pointer to .\|.\|.''.
877: Moreover, an array identifier is not an lvalue
878: expression.
879: Likewise, an identifier which is declared
880: ``function returning .\|.\|.'',
881: when used except in the function-name position
882: of a call, is converted to ``pointer to function returning .\|.\|.''.
883: .PP
884: A
885: constant is a primary expression.
886: Its type may be
887: \fBint\fR,
888: \fBlong\fR,
889: or
890: .B
891: double
892: .R
893: depending on its form.
894: Character constants have type
895: .B
896: int
897: .R
898: and floating constants have type
899: .B
900: double\fR.
901: .R
902: .PP
903: A string is a primary expression.
904: Its type is originally ``array of
905: \fBchar\fR'',
906: but following
907: the same rule given above for identifiers,
908: this is modified to ``pointer to
909: \fBchar\fR'' and
910: the
911: result is a pointer to the first character
912: in the string.
913: (There is an exception in certain initializers;
914: see ``Initialization'' under ``DECLARATIONS.'')
915: .PP
916: A parenthesized expression is a primary expression
917: whose type and value are identical
918: to those of the unadorned expression.
919: The presence of parentheses does
920: not affect whether the expression is an
921: lvalue.
922: .PP
923: A primary expression followed by an expression in square
924: brackets is a primary expression.
925: The intuitive meaning is that of a subscript.
926: Usually, the primary expression has type ``pointer to .\|.\|.'',
927: the subscript expression is
928: \fBint\fR,
929: and the type of the result is ``\|.\|.\|.\|''.
930: The expression
931: .B
932: E1[E2]
933: .R
934: is
935: identical (by definition) to
936: .B
937: \(**((E1)\(plE2))\fR.
938: All the clues
939: needed to understand
940: this notation are contained in this subpart together
941: with the discussions
942: in ``Unary Operators'' and ``Additive Operators'' on identifiers,
943: .B
944: \(**
945: .R
946: and
947: .B
948: \(pl
949: .R
950: respectively.
951: The implications are summarized under ``Arrays, Pointers, and Subscripting''
952: under ``TYPES REVISITED.''
953: .PP
954: A function call is a primary expression followed by parentheses
955: containing a possibly
956: empty, comma-separated list of expressions
957: which constitute the actual arguments to the
958: function.
959: The primary expression must be of type ``function returning .\|.\|.,''
960: and the result of the function call is of type ``\|.\|.\|.\|''.
961: As indicated
962: below, a hitherto unseen identifier followed
963: immediately by a left parenthesis
964: is contextually declared
965: to represent a function returning
966: an integer;
967: thus in the most common case, integer-valued functions
968: need not be declared.
969: .PP
970: Any actual arguments of type
971: .B
972: float
973: .R
974: are
975: converted to
976: .B
977: double
978: .R
979: before the call.
980: Any of type
981: .B
982: char
983: .R
984: or
985: .B
986: short
987: .R
988: are converted to
989: .B
990: int\fR.
991: .R
992: Array names are converted to pointers.
993: No other conversions are performed automatically;
994: in particular, the compiler does not compare
995: the types of actual arguments with those of formal
996: arguments.
997: If conversion is needed, use a cast;
998: see ``Unary Operators'' and ``Type Names'' under
999: ``DECLARATIONS.''
1000: .PP
1001: In preparing for the call to a function,
1002: a copy is made of each actual parameter.
1003: Thus, all argument passing in C is strictly by value.
1004: A function may
1005: change the values of its formal parameters, but
1006: these changes cannot affect the values
1007: of the actual parameters.
1008: It is possible
1009: to pass a pointer on the understanding
1010: that the function may change the value
1011: of the object to which the pointer points.
1012: An array name is a pointer expression.
1013: The order of evaluation of arguments is undefined by the language;
1014: take note that the various compilers differ.
1015: Recursive calls to any
1016: function are permitted.
1017: .PP
1018: A primary expression followed by a dot followed by an identifier
1019: is an expression.
1020: The first expression must be a structure or a union, and the identifier
1021: must name a member of the structure or union.
1022: The value is the named member of the structure or union, and it is
1023: an lvalue if the first expression is an lvalue.
1024: .PP
1025: A primary expression followed by an arrow (built from
1026: .B
1027: \(mi
1028: .R
1029: and
1030: .B
1031: >
1032: .R
1033: )
1034: followed by an identifier
1035: is an expression.
1036: The first expression must be a pointer to a structure or a union
1037: and the identifier must name a member of that structure or union.
1038: The result is an lvalue referring to the named member
1039: of the structure or union
1040: to which the pointer expression points.
1041: Thus the expression
1042: .B
1043: E1\(mi>MOS
1044: .R
1045: is the same as
1046: .B
1047: (\(**E1).MOS\fR.
1048: .R
1049: Structures and unions are discussed in
1050: ``Structure, Union, and Enumeration Declarations'' under
1051: ``DECLARATIONS.''
1052: .NH 2
1053: Unary Operators
1054: .PP
1055: Expressions with unary operators
1056: group right to left.
1057: .tr ~~
1058: .DS
1059: \fIunary-expression:
1060: \(** expression
1061: & lvalue
1062: \(mi expression
1063: ! expression
1064: \s+2~\s0 expression
1065: \(pl\(pl lvalue
1066: \(mi\(milvalue
1067: lvalue \(pl\(pl
1068: lvalue \(mi\(mi
1069: ( type-name ) expression\fR
1070: sizeof\fI expression\fR
1071: sizeof\fI ( type-name )\fR
1072: .DE
1073: .PP
1074: The unary
1075: .B
1076: \(**
1077: .R
1078: operator
1079: means
1080: .I
1081: indirection
1082: .R
1083: ;
1084: the expression must be a pointer, and the result
1085: is an lvalue referring to the object to
1086: which the expression points.
1087: If the type of the expression is ``pointer to .\|.\|.,''
1088: the type of the result is ``\|.\|.\|.\|''.
1089: .PP
1090: The result of the unary
1091: .B
1092: &
1093: .R
1094: operator is a pointer
1095: to the object referred to by the
1096: lvalue.
1097: If the type of the lvalue is ``\|.\|.\|.\|'',
1098: the type of the result is ``pointer to .\|.\|.''.
1099: .PP
1100: The result
1101: of the unary
1102: .B
1103: \(mi
1104: .R
1105: operator
1106: is the negative of its operand.
1107: The usual arithmetic conversions are performed.
1108: The negative of an unsigned quantity is computed by
1109: subtracting its value from
1110: 2\v'-0.5'\fIn\fR\^\v'0.5' where \fIn\fR\^ is the number of bits in
1111: the corresponding signed type.
1112: .sp
1113: .tr ~~
1114: There is no unary
1115: .B
1116: \(pl
1117: .R
1118: operator.
1119: .PP
1120: The result of the logical negation operator
1121: .B
1122: !
1123: .R
1124: is one if the value of its operand is zero, zero if the value of its
1125: operand is nonzero.
1126: The type of the result is
1127: .B
1128: int\fR.
1129: .R
1130: It is applicable to any arithmetic type
1131: or to pointers.
1132: .PP
1133: The
1134: .B
1135: \s+2~\s0
1136: .R
1137: operator yields the one's complement of its operand.
1138: The usual arithmetic conversions are performed.
1139: The type of the operand must be integral.
1140: .PP
1141: The object referred to by the lvalue operand of prefix
1142: .B
1143: \(pl\(pl
1144: .R
1145: is incremented.
1146: The value is the new value of the operand
1147: but is not an lvalue.
1148: The expression
1149: .B
1150: \(pl\(plx
1151: .R
1152: is equivalent to
1153: \fBx=x\(pl1\fR.
1154: See the discussions ``Additive Operators'' and ``Assignment
1155: Operators'' for information on conversions.
1156: .PP
1157: The lvalue operand of prefix
1158: .B
1159: \(mi\(mi
1160: .R
1161: is decremented
1162: analogously to the
1163: prefix
1164: .B
1165: \(pl\(pl
1166: .R
1167: operator.
1168: .PP
1169: When postfix
1170: .B
1171: \(pl\(pl
1172: .R
1173: is applied to an lvalue,
1174: the result is the value of the object referred to by the lvalue.
1175: After the result is noted, the object
1176: is incremented in the same
1177: manner as for the prefix
1178: .B
1179: \(pl\(pl
1180: .R
1181: operator.
1182: The type of the result is the same as the type of the lvalue expression.
1183: .PP
1184: When postfix
1185: .B
1186: \(mi\(mi
1187: .R
1188: is applied to an lvalue,
1189: the result is the value of the object referred to by the lvalue.
1190: After the result is noted, the object
1191: is decremented in the manner as for the prefix
1192: .B
1193: \(mi\(mi
1194: .R
1195: operator.
1196: The type of the result is the same as the type of the lvalue
1197: expression.
1198: .PP
1199: An expression preceded by the parenthesized name of a data type
1200: causes conversion of the value of the expression to the named type.
1201: This construction is called a
1202: .I
1203: cast\fR.
1204: .R
1205: Type names are described in ``Type Names'' under ``Declarations.''
1206: .PP
1207: The
1208: .B
1209: sizeof
1210: .R
1211: operator yields the size
1212: in bytes of its operand.
1213: (A
1214: .I
1215: byte
1216: .R
1217: is undefined by the language
1218: except in terms of the value of
1219: .B
1220: sizeof\fR.
1221: .R
1222: However, in all existing implementations,
1223: a byte is the space required to hold a
1224: \fBchar.\fR)
1225: When applied to an array, the result is the total
1226: number of bytes in the array.
1227: The size is determined from
1228: the declarations of
1229: the objects in the expression.
1230: This expression is semantically an
1231: .B
1232: unsigned
1233: .R
1234: constant and may
1235: be used anywhere a constant is required.
1236: Its major use is in communication with routines
1237: like storage allocators and I/O systems.
1238: .PP
1239: The
1240: .B
1241: sizeof
1242: .R
1243: operator
1244: may also be applied to a parenthesized type name.
1245: In that case it yields the size in bytes of an object
1246: of the indicated type.
1247: .PP
1248: The construction
1249: \fBsizeof(\fItype\|\fR\^)\fR\^
1250: is taken to be a unit,
1251: so the expression
1252: \fBsizeof(\fItype\|\fB)-2\fR
1253: is the same as
1254: \fB(sizeof(\fItype\|\fB))-2\fR.
1255: .NH 2
1256: Multiplicative Operators
1257: .PP
1258: The multiplicative operators
1259: \fB\(**\fR,
1260: \fB/\fR,
1261: and
1262: .B
1263: %
1264: .R
1265: group left to right.
1266: The usual arithmetic conversions are performed.
1267: .DS
1268: \fImultiplicative expression:
1269: expression \(** expression
1270: expression / expression
1271: expression % expression\fR
1272: .DE
1273: .PP
1274: The binary
1275: .B
1276: \(**
1277: .R
1278: operator indicates multiplication.
1279: The
1280: .B
1281: \(**
1282: .R
1283: operator is associative,
1284: and expressions with several multiplications at the same
1285: level may be rearranged by the compiler.
1286: The binary
1287: .B
1288: /
1289: .R
1290: operator indicates division.
1291: .PP
1292: The binary
1293: .B
1294: %
1295: .R
1296: operator yields the remainder
1297: from the division of the first expression by the second.
1298: The operands must be integral.
1299: .PP
1300: When positive integers are divided, truncation is toward 0;
1301: but the form of truncation is machine-dependent
1302: if either operand is negative.
1303: On all machines covered by this manual,
1304: the remainder has the same sign as the dividend.
1305: It is always true that
1306: .B
1307: (a/b)\(**b\ \(pl a%b
1308: .R
1309: is equal to
1310: .B
1311: a
1312: .R
1313: (if
1314: .B
1315: b
1316: .R
1317: is not 0).
1318: .NH 2
1319: Additive Operators
1320: .PP
1321: The additive operators
1322: .B
1323: \(pl
1324: .R
1325: and
1326: .B
1327: \(mi
1328: .R
1329: group left to right.
1330: The usual arithmetic conversions are performed.
1331: There are some additional type possibilities for each operator.
1332: .DS
1333: \fIadditive-expression:
1334: expression \(pl expression
1335: expression \(mi expression\fR
1336: .DE
1337: .PP
1338: The result of the
1339: .B
1340: \(pl
1341: .R
1342: operator is the sum of the operands.
1343: A pointer to an object in an array and
1344: a value of any integral type
1345: may be added.
1346: The latter is in all cases converted to
1347: an address offset
1348: by multiplying it
1349: by the length of the object to which the
1350: pointer points.
1351: The result is a pointer
1352: of the same type as the original pointer
1353: which points to another object in the same array,
1354: appropriately offset from the original object.
1355: Thus if
1356: .B
1357: P
1358: .R
1359: is a pointer
1360: to an object in an array, the expression
1361: .B
1362: P\(pl1
1363: .R
1364: is a pointer
1365: to the next object in the array.
1366: No further type combinations are allowed for pointers.
1367: .PP
1368: The
1369: .B
1370: \(pl
1371: .R
1372: operator is associative,
1373: and expressions with several additions at the same level may
1374: be rearranged by the compiler.
1375: .PP
1376: The result of the
1377: .B
1378: \(mi
1379: .R
1380: operator is the difference of the operands.
1381: The usual arithmetic conversions are performed.
1382: Additionally,
1383: a value of any integral type
1384: may be subtracted from a pointer,
1385: and then the same conversions for addition apply.
1386: .PP
1387: If two pointers to objects of the same type are subtracted,
1388: the result is converted
1389: (by division by the length of the object)
1390: to an
1391: .B
1392: int
1393: .R
1394: representing the number of
1395: objects separating
1396: the pointed-to objects.
1397: This conversion will in general give unexpected
1398: results unless the pointers point
1399: to objects in the same array, since pointers, even
1400: to objects of the same type, do not necessarily differ
1401: by a multiple of the object length.
1402: .NH 2
1403: Shift Operators
1404: .PP
1405: The shift operators
1406: .B
1407: <<
1408: .R
1409: and
1410: .B
1411: >>
1412: .R
1413: group left to right.
1414: Both perform the usual arithmetic conversions on their operands,
1415: each of which must be integral.
1416: Then the right operand is converted to
1417: \fBint\fR;
1418: the type of the result is that of the left operand.
1419: The result is undefined if the right operand is negative
1420: or greater than or equal to the length of the object in bits.
1421: On the VAX a negative right operand is interpreted as reversing
1422: the direction of the shift.
1423: .DS
1424: \fIshift-expression:
1425: expression << expression
1426: expression >> expression\fR
1427: .DE
1428: .PP
1429: The value of
1430: .B
1431: E1<<E2
1432: .R
1433: is
1434: .B
1435: E1
1436: .R
1437: (interpreted as a bit
1438: pattern) left-shifted
1439: .B
1440: E2
1441: .R
1442: bits.
1443: Vacated bits are 0 filled.
1444: The value of
1445: .B
1446: E1>>E2
1447: .R
1448: is
1449: .B
1450: E1
1451: .R
1452: right-shifted
1453: .B
1454: E2
1455: .R
1456: bit positions.
1457: The right shift is guaranteed to be logical
1458: (0 fill)
1459: if
1460: .B
1461: E1
1462: .R
1463: is
1464: \fBunsigned\fR;
1465: otherwise, it may be
1466: arithmetic.
1467: .NH 2
1468: Relational Operators
1469: .PP
1470: The relational operators group left to right.
1471: .DS
1472: \fIrelational-expression:
1473: expression < expression
1474: expression > expression
1475: expression <= expression
1476: expression >= expression\fR
1477: .DE
1478: .PP
1479: The operators
1480: .B
1481: <
1482: .R
1483: (less than),
1484: .B
1485: >
1486: .R
1487: (greater than), \fB<=\fR
1488: (less than
1489: or equal to), and
1490: .B
1491: >=
1492: .R
1493: (greater than or equal to)
1494: all yield 0 if the specified relation is false
1495: and 1 if it is true.
1496: The type of the result is
1497: .B
1498: int\fR.
1499: The usual arithmetic conversions are performed.
1500: Two pointers may be compared;
1501: the result depends on the relative locations in the address space
1502: of the pointed-to objects.
1503: Pointer comparison is portable only when the pointers point to objects
1504: in the same array.
1505: .NH 2
1506: Equality Operators
1507: .PP
1508: .DS
1509: \fIequality-expression:
1510: expression == expression
1511: expression != expression\fR
1512: .DE
1513: .PP
1514: The
1515: .B
1516: ==
1517: .R
1518: (equal to) and the
1519: .B
1520: !=
1521: .R
1522: (not equal to) operators
1523: are exactly analogous to the relational
1524: operators except for their lower
1525: precedence.
1526: (Thus
1527: .B
1528: a<b\ ==\ c<d
1529: .R
1530: is 1 whenever
1531: .B
1532: a<b
1533: .R
1534: and
1535: .B
1536: c<d
1537: .R
1538: have the same truth value).
1539: .PP
1540: A pointer may be compared to an integer
1541: only if the
1542: integer is the constant 0.
1543: A pointer to which 0 has been assigned is guaranteed
1544: not to point to any object
1545: and will appear to be equal to 0.
1546: In conventional usage, such a pointer is considered to be null.
1547: .NH 2
1548: Bitwise \s-1AND\s0 Operator
1549: .PP
1550: .DS
1551: \fIand-expression:
1552: expression & expression\fR
1553: .DE
1554: .PP
1555: The
1556: .B
1557: &
1558: .R
1559: operator is associative,
1560: and expressions involving
1561: .B
1562: &
1563: .R
1564: may be rearranged.
1565: The usual arithmetic conversions are performed.
1566: The result is the bitwise
1567: AND
1568: function of the operands.
1569: The operator applies only to integral
1570: operands.
1571: .NH 2
1572: Bitwise Exclusive \s-1OR\s0 Operator
1573: .DS
1574: \fIexclusive-or-expression:
1575: expression ^ expression\fR
1576: .DE
1577: .PP
1578: The
1579: .B
1580: ^
1581: .R
1582: operator is associative,
1583: and expressions involving
1584: .B
1585: ^
1586: .R
1587: may be rearranged.
1588: The usual arithmetic conversions are performed;
1589: the result is
1590: the bitwise exclusive
1591: OR
1592: function of
1593: the operands.
1594: The operator applies only to integral
1595: operands.
1596: .NH 2
1597: Bitwise Inclusive \s-1OR\s0 Operator
1598: .DS
1599: \fIinclusive-or-expression:
1600: expression | expression\fR
1601: .DE
1602: .PP
1603: The
1604: .B
1605: |
1606: .R
1607: operator is associative,
1608: and expressions involving
1609: .B
1610: |
1611: .R
1612: may be rearranged.
1613: The usual arithmetic conversions are performed;
1614: the result is the bitwise inclusive
1615: OR
1616: function of its operands.
1617: The operator applies only to integral
1618: operands.
1619: .NH 2
1620: Logical \s-1AND\s0 Operator
1621: .DS
1622: \fIlogical-and-expression:
1623: expression && expression\fR
1624: .DE
1625: .PP
1626: The
1627: .B
1628: &&
1629: .R
1630: operator groups left to right.
1631: It returns 1 if both its operands
1632: evaluate to nonzero, 0 otherwise.
1633: Unlike
1634: \fB&\fR,
1635: .B
1636: &&
1637: .R
1638: guarantees left to right
1639: evaluation; moreover, the second operand is not evaluated
1640: if the first operand is 0.
1641: .PP
1642: The operands need not have the same type, but each
1643: must have one of the fundamental
1644: types or be a pointer.
1645: The result is always
1646: .B
1647: int\fR.
1648: .R
1649: .NH 2
1650: Logical \s-1OR\s0 Operator
1651: .DS
1652: \fIlogical-or-expression:
1653: expression || expression\fR
1654: .DE
1655: .PP
1656: The
1657: .B
1658: ||
1659: .R
1660: operator groups left to right.
1661: It returns 1 if either of its operands
1662: evaluates to nonzero, 0 otherwise.
1663: Unlike
1664: \fB|\fR,
1665: .B
1666: ||
1667: .R
1668: guarantees left to right evaluation; moreover,
1669: the second operand is not evaluated
1670: if the value of the first operand is nonzero.
1671: .PP
1672: The operands need not have the same type, but each
1673: must
1674: have one of the fundamental types
1675: or be a pointer.
1676: The result is always
1677: .B
1678: int\fR.
1679: .R
1680: .NH 2
1681: Conditional Operator
1682: .DS
1683: \fIconditional-expression:
1684: expression ? expression : expression\fR
1685: .DE
1686: .PP
1687: Conditional expressions group right to left.
1688: The first expression is evaluated;
1689: and if it is nonzero, the result is the value of the
1690: second expression, otherwise that of third expression.
1691: If possible, the usual arithmetic conversions are performed
1692: to bring the second and third expressions to a common type.
1693: If both are structures or unions of the same type,
1694: the result has the type of the structure or union.
1695: If both pointers are of the same type,
1696: the result has the common type.
1697: Otherwise, one must be a pointer and the other the constant 0,
1698: and the result has the type of the pointer.
1699: Only one of the second and third
1700: expressions is evaluated.
1701: .NH 2
1702: Assignment Operators
1703: .PP
1704: There are a number of assignment operators,
1705: all of which group right to left.
1706: All require an lvalue as their left operand,
1707: and the type of an assignment expression is that
1708: of its left operand.
1709: The value is the value stored in the
1710: left operand after the assignment has taken place.
1711: The two parts of a compound assignment operator are separate
1712: tokens.
1713: .DS
1714: \fIassignment-expression:
1715: lvalue = expression
1716: lvalue \(pl= expression
1717: lvalue \(mi= expression
1718: lvalue \(**= expression
1719: lvalue /= expression
1720: lvalue %= expression
1721: lvalue >>= expression
1722: lvalue <<= expression
1723: lvalue &= expression
1724: lvalue ^= expression
1725: lvalue |= expression\fR
1726: .DE
1727: .PP
1728: In the simple assignment with
1729: \fB=\fR,
1730: the value of the expression replaces that of the object
1731: referred
1732: to by the lvalue.
1733: If both operands have arithmetic type,
1734: the right operand is converted to the type of the left
1735: preparatory to the assignment.
1736: Second, both operands may be structures or unions of the same type.
1737: Finally, if the left operand is a pointer, the right operand must in general be a pointer
1738: of the same type.
1739: However, the constant 0 may be assigned to a pointer;
1740: it is guaranteed that this value will produce a null
1741: pointer distinguishable from a pointer to any object.
1742: .PP
1743: The behavior of an expression
1744: of the form
1745: \fBE1\fR\^ \fIop\fR\^ = \fBE2\fR\^
1746: may be inferred by
1747: taking it as equivalent to
1748: \fBE1 = E1 \fIop\fR\^ (\fBE2\fR\^);
1749: however,
1750: .B
1751: E1
1752: .R
1753: is evaluated only once.
1754: In
1755: .B
1756: \(pl=
1757: .R
1758: and
1759: \fB\(mi=\fR,
1760: the left operand may be a pointer; in which case, the (integral) right
1761: operand is converted as explained
1762: in ``Additive Operators.''
1763: All right operands and all nonpointer left operands must
1764: have arithmetic type.
1765: .NH 2
1766: Comma Operator
1767: .DS
1768: \fIcomma-expression:
1769: expression , expression\fR
1770: .DE
1771: .PP
1772: A pair of expressions separated by a comma is evaluated
1773: left to right, and the value of the left expression is
1774: discarded.
1775: The type and value of the result are the
1776: type and value of the right operand.
1777: This operator groups left to right.
1778: In contexts where comma is given a special meaning,
1779: e.g., in lists of actual arguments
1780: to functions (see ``Primary Expressions'') and lists
1781: of initializers (see ``Initialization'' under ``DECLARATIONS''),
1782: the comma operator as described in this subpart
1783: can only appear in parentheses. For example,
1784: .DS
1785: \fBf(a, (t=3, t\(pl2), c)\fR
1786: .DE
1787: .LP
1788: has three arguments, the second of which has the value 5.
1789: .NH 1
1790: Declarations
1791: .PP
1792: Declarations are used to specify the interpretation
1793: which C gives to each identifier; they do not necessarily
1794: reserve storage associated with the identifier.
1795: Declarations have the form
1796: .DS
1797: \fIdeclaration:
1798: decl-specifiers declarator-list\v'0.5'\s-2opt\s0\v'-0.5' ;\fR
1799: .DE
1800: .PP
1801: The declarators in the declarator-list
1802: contain the identifiers being declared.
1803: The decl-specifiers
1804: consist of a sequence of type and storage class specifiers.
1805: .DS
1806: \fIdecl-specifiers:
1807: type-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
1808: sc-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'\fR
1809: .DE
1810: .PP
1811: The list must be self-consistent in a way described below.
1812: .NH 2
1813: Storage Class Specifiers
1814: .PP
1815: The sc-specifiers are:
1816: .DS
1817: \fIsc-specifier:\fB
1818: auto
1819: static
1820: extern
1821: register
1822: typedef\fR
1823: .DE
1824: .PP
1825: The
1826: .B
1827: typedef
1828: .R
1829: specifier does not reserve storage
1830: and is called a ``storage class specifier'' only for syntactic convenience.
1831: See ``Typedef'' for more information.
1832: The meanings of the various storage classes were discussed in ``Names.''
1833: .PP
1834: The
1835: \fBauto\fR,
1836: \fBstatic\fR,
1837: and
1838: .B
1839: register
1840: .R
1841: declarations also serve as definitions
1842: in that they cause an appropriate amount of storage to be reserved.
1843: In the
1844: .B
1845: extern
1846: .R
1847: case,
1848: there must be an external definition (see ``External Definitions'')
1849: for the given identifiers
1850: somewhere outside the function in which they are declared.
1851: .PP
1852: A
1853: .B
1854: register
1855: .R
1856: declaration is best thought of as an
1857: .B
1858: auto
1859: .R
1860: declaration, together with a hint to the compiler
1861: that the variables declared will be heavily used.
1862: Only the first few
1863: such declarations in each function are effective.
1864: Moreover, only variables of certain types will be stored in registers;
1865: on the
1866: PDP-11,
1867: they are
1868: .B
1869: int
1870: .R
1871: or pointer.
1872: One other restriction applies to register variables:
1873: the address-of operator
1874: .B
1875: &
1876: .R
1877: cannot be applied to them.
1878: Smaller, faster programs can be expected if register declarations
1879: are used appropriately,
1880: but future improvements in code generation
1881: may render them unnecessary.
1882: .PP
1883: At most, one sc-specifier may be given in a declaration.
1884: If the sc-specifier is missing from a declaration, it
1885: is taken to be
1886: .B
1887: auto
1888: .R
1889: inside a function,
1890: .B
1891: extern
1892: .R
1893: outside.
1894: Exception:
1895: functions are never
1896: automatic.
1897: .NH 2
1898: Type Specifiers
1899: .PP
1900: The type-specifiers are
1901: .DS
1902: \fItype-specifier:
1903: struct-or-union-specifier
1904: typedef-name
1905: enum-specifier
1906: basic-type-specifier:
1907: basic-type
1908: basic-type basic-type-specifiers
1909: basic-type:\fB
1910: char
1911: short
1912: int
1913: long
1914: unsigned
1915: float
1916: double
1917: void\fR
1918: .DE
1919: .PP
1920: At most one of the words \fBlong\fR or \fBshort\fR
1921: may be specified in conjunction with \fBint\fR;
1922: the meaning is the same as if \fBint\fR were not mentioned.
1923: The word \fBlong\fR may be specified in conjunction with
1924: \fBfloat\fR;
1925: the meaning is the same as \fBdouble\fR.
1926: The word \fBunsigned\fR may be specified alone, or
1927: in conjunction with \fBint\fR or any of its short
1928: or long varieties, or with \fBchar\fR.
1929: .PP
1930: Otherwise, at most on type-specifier may be
1931: given in a declaration.
1932: In particular, adjectival use of \fBlong\fR,
1933: \fBshort\fR, or \fBunsigned\fR is not permitted
1934: with \fBtypedef\fR names.
1935: If the type-specifier is missing from a declaration,
1936: it is taken to be \fBint\fR.
1937: .PP
1938: Specifiers for structures, unions, and enumerations are discussed in
1939: ``Structure, Union, and Enumeration Declarations.''
1940: Declarations with
1941: .B
1942: typedef
1943: .R
1944: names are discussed in ``Typedef.''
1945: .NH 2
1946: Declarators
1947: .PP
1948: The declarator-list appearing in a declaration
1949: is a comma-separated sequence of declarators,
1950: each of which may have an initializer.
1951: .DS
1952: \fIdeclarator-list:
1953: init-declarator
1954: init-declarator , declarator-list
1955: .DE
1956: .DS
1957: \fIinit-declarator:
1958: declarator initializer\v'0.5'\s-2opt\s0\v'-0.5'\fR
1959: .DE
1960: .PP
1961: Initializers are discussed in ``Initialization''.
1962: The specifiers in the declaration
1963: indicate the type and storage class of the objects to which the
1964: declarators refer.
1965: Declarators have the syntax:
1966: .DS
1967: \fIdeclarator:
1968: identifier
1969: ( declarator )
1970: \(** declarator
1971: declarator ()
1972: declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]\fR
1973: .DE
1974: .PP
1975: The grouping is
1976: the same as in expressions.
1977: .NH 2
1978: Meaning of Declarators
1979: .PP
1980: Each declarator is taken to be
1981: an assertion that when a construction of
1982: the same form as the declarator appears in an expression,
1983: it yields an object of the indicated
1984: type and storage class.
1985: .PP
1986: Each declarator contains exactly one identifier; it is this identifier that
1987: is declared.
1988: If an unadorned identifier appears
1989: as a declarator, then it has the type
1990: indicated by the specifier heading the declaration.
1991: .PP
1992: A declarator in parentheses is identical to the unadorned declarator,
1993: but the binding of complex declarators may be altered by parentheses.
1994: See the examples below.
1995: .PP
1996: Now imagine a declaration
1997: .DS
1998: \fBT D1\fR
1999: .DE
2000: .LP
2001: where
2002: .B
2003: T
2004: .R
2005: is a type-specifier (like
2006: \fBint\fR,
2007: etc.)
2008: and
2009: .B
2010: D1
2011: .R
2012: is a declarator.
2013: Suppose this declaration makes the identifier have type
2014: ``\|.\|.\|.\|
2015: .B
2016: T
2017: .R
2018: ,''
2019: where the ``\|.\|.\|.\|'' is empty if
2020: .B
2021: D1
2022: .R
2023: is just a plain identifier
2024: (so that the type of
2025: .B
2026: x
2027: .R
2028: in
2029: \fB`int x''\fR
2030: is just
2031: \fBint\fR).
2032: Then if
2033: .B
2034: D1
2035: .R
2036: has the form
2037: .DS
2038: \fB\(**D\fR
2039: .DE
2040: .LP
2041: the type of the contained identifier is
2042: ``\|.\|.\|.\| pointer to
2043: .B
2044: T
2045: .R
2046: \&.''
2047: .PP
2048: If
2049: .B
2050: D1
2051: .R
2052: has the form
2053: .DS
2054: \fBD\|(\|\|)\|\fR
2055: .DE
2056: .LP
2057: then the contained identifier has the type
2058: ``\|.\|.\|. function returning
2059: \fBT\fR.''
2060: .LP
2061: If
2062: .B
2063: D1
2064: .R
2065: has the form
2066: .DS
2067: \fBD\|[\|\fIconstant-expression\fB\|]\fR
2068: .DE
2069: .LP
2070: or
2071: .DS
2072: \fBD\|[\|]\|\fR
2073: .DE
2074: .LP
2075: then the contained identifier has type
2076: ``\|.\|.\|.\| array of
2077: \fBT\fR.''
2078: In the first case, the constant
2079: expression
2080: is an expression
2081: whose value is determinable at compile time
2082: , whose type is
2083: .B
2084: int\fR,
2085: and whose value is positive.
2086: (Constant expressions are defined precisely in ``Constant Expressions.'')
2087: When several ``array of'' specifications are adjacent, a multidimensional
2088: array is created;
2089: the constant expressions which specify the bounds
2090: of the arrays may be missing only for the first member of the sequence.
2091: This elision is useful when the array is external
2092: and the actual definition, which allocates storage,
2093: is given elsewhere.
2094: The first constant expression may also be omitted
2095: when the declarator is followed by initialization.
2096: In this case the size is calculated from the number
2097: of initial elements supplied.
2098: .PP
2099: An array may be constructed from one of the basic types, from a pointer,
2100: from a structure or union,
2101: or from another array (to generate a multidimensional array).
2102: .PP
2103: Not all the possibilities
2104: allowed by the syntax above are actually
2105: permitted.
2106: The restrictions are as follows:
2107: functions may not return
2108: arrays or functions
2109: although they may return pointers;
2110: there are no arrays of functions although
2111: there may be arrays of pointers to functions.
2112: Likewise, a structure or union may not contain a function;
2113: but it may contain a pointer to a function.
2114: .PP
2115: As an example, the declaration
2116: .DS
2117: \fBint i, \(**ip, f(), \(**fip(), (\(**pfi)();\fR
2118: .DE
2119: .LP
2120: declares an integer
2121: \fBi\fR,
2122: a pointer
2123: .B
2124: ip
2125: .R
2126: to an integer,
2127: a function
2128: .B
2129: f
2130: .R
2131: returning an integer,
2132: a function
2133: .B
2134: fip
2135: .R
2136: returning a pointer to an integer,
2137: and a pointer
2138: .B
2139: pfi
2140: .R
2141: to a function which
2142: returns an integer.
2143: It is especially useful to compare the last two.
2144: The binding of
2145: .B
2146: \(**fip()
2147: .R
2148: is
2149: .B
2150: \(**(fip())\fR.
2151: .R
2152: The declaration suggests,
2153: and the same construction in an expression
2154: requires, the calling of a function
2155: .B
2156: fip\fR.
2157: .R
2158: Using indirection through the (pointer) result
2159: to yield an integer.
2160: In the declarator
2161: \fB(\(**pfi)()\fR,
2162: the extra parentheses are necessary, as they are also
2163: in an expression, to indicate that indirection through
2164: a pointer to a function yields a function, which is then called;
2165: it returns an integer.
2166: .PP
2167: As another example,
2168: .DS
2169: \fBfloat fa[17], \(**afp[17];\fR
2170: .DE
2171: .LP
2172: declares an array of
2173: .B
2174: float
2175: .R
2176: numbers and an array of
2177: pointers to
2178: .B
2179: float
2180: .R
2181: numbers.
2182: Finally,
2183: .DS
2184: \fBstatic int x3d[3][5][7];\fR
2185: .DE
2186: .LP
2187: declares a static 3-dimensional array of integers,
2188: with rank 3\(mu5\(mu7.
2189: In complete detail,
2190: .B
2191: x3d
2192: .R
2193: is an array of three items;
2194: each item is an array of five arrays;
2195: each of the latter arrays is an array of seven
2196: integers.
2197: Any of the expressions
2198: \fBx3d\fR,
2199: \fBx3d[i]\fR,
2200: \fBx3d[i][j]\fR,
2201: .B
2202: x3d[i][j][k]
2203: .R
2204: may reasonably appear in an expression.
2205: The first three have type ``array''
2206: and the last has type
2207: .B
2208: int\fR.
2209: .R
2210: .NH 2
2211: Structure and Union Declarations
2212: .PP
2213: A structure
2214: is an object consisting of a sequence of named members.
2215: Each member may have any type.
2216: A union is an object which may, at a given time, contain any one
2217: of several members.
2218: Structure and union specifiers have the same form.
2219: .DS
2220: \fIstruct-or-union-specifier:
2221: struct-or-union { struct-decl-list }
2222: struct-or-union identifier { struct-decl-list }
2223: struct-or-union identifier
2224: .DE
2225: .DS
2226: \fIstruct-or-union:\fB
2227: struct
2228: union\fR
2229: .DE
2230: .PP
2231: The
2232: struct-decl-list
2233: .ne 4
2234: is a sequence of declarations for the members of the structure or union:
2235: .DS
2236: \fIstruct-decl-list:
2237: struct-declaration
2238: struct-declaration struct-decl-list
2239: .DE
2240: .DS
2241: \fIstruct-declaration:
2242: type-specifier struct-declarator-list ;
2243: .DE
2244: .DS
2245: \fIstruct-declarator-list:
2246: struct-declarator
2247: struct-declarator , struct-declarator-list\fR
2248: .DE
2249: .PP
2250: In the usual case, a struct-declarator is just a declarator
2251: for a member of a structure or union.
2252: A structure member may also consist of a specified number of bits.
2253: Such a member is also called a
2254: .I
2255: field ;
2256: .R
2257: its length,
2258: a non-negative constant expression,
2259: is set off from the field name by a colon.
2260: .DS
2261: \fIstruct-declarator:
2262: declarator
2263: declarator : constant-expression
2264: : constant-expression\fR
2265: .DE
2266: .PP
2267: Within a structure, the objects declared
2268: have addresses which increase as the declarations
2269: are read left to right.
2270: Each nonfield member of a structure
2271: begins on an addressing boundary appropriate
2272: to its type;
2273: therefore, there may
2274: be unnamed holes in a structure.
2275: Field members are packed into machine integers;
2276: they do not straddle words.
2277: A field which does not fit into the space remaining in a word
2278: is put into the next word.
2279: No field may be wider than a word.
2280: .PP
2281: Fields are assigned right to left
2282: on the
2283: PDP-11
2284: and
2285: VAX-11,
2286: left to right on the 3B 20.
2287: .PP
2288: A struct-declarator with no declarator, only a colon and a width,
2289: indicates an unnamed field useful for padding to conform
2290: to externally-imposed layouts.
2291: As a special case, a field with a width of 0
2292: specifies alignment of the next field at an implementation dependant boundary.
2293: .PP
2294: The language does not restrict the types of things that
2295: are declared as fields,
2296: but implementations are not required to support any but
2297: integer fields.
2298: Moreover,
2299: even
2300: .B
2301: int
2302: .R
2303: fields may be considered to be unsigned.
2304: On the
2305: PDP-11,
2306: fields are not signed and have only integer values;
2307: on the
2308: VAX-11,
2309: fields declared with
2310: .B
2311: int
2312: .R
2313: are treated as containing a sign.
2314: For these reasons,
2315: it is strongly recommended that fields be declared as
2316: .B
2317: unsigned\fR.
2318: .R
2319: In all implementations,
2320: there are no arrays of fields,
2321: and the address-of operator
2322: .B
2323: &
2324: .R
2325: may not be applied to them, so that there are no pointers to
2326: fields.
2327: .PP
2328: A union may be thought of as a structure all of whose members
2329: begin at offset 0 and whose size is sufficient to contain
2330: any of its members.
2331: At most, one of the members can be stored in a union
2332: at any time.
2333: .PP
2334: A structure or union specifier of the second form, that is, one of
2335: .DS
2336: \fBstruct \fIidentifier { struct-decl-list \fR}
2337: \fBunion \fIidentifier { struct-decl-list \fR}
2338: .DE
2339: .LP
2340: declares the identifier to be the
2341: .I
2342: structure tag
2343: .R
2344: (or union tag)
2345: of the structure specified by the list.
2346: A subsequent declaration may then use
2347: the third form of specifier, one of
2348: .DS
2349: \fBstruct \fIidentifier\fR
2350: \fBunion \fIidentifier\fR
2351: .DE
2352: .PP
2353: Structure tags allow definition of self-referential
2354: structures. Structure tags also
2355: permit the long part of the declaration to be
2356: given once and used several times.
2357: It is illegal to declare a structure or union
2358: which contains an instance of
2359: itself, but a structure or union may contain a pointer to an instance of itself.
2360: .PP
2361: The third form of a structure or union specifier may be
2362: used prior to a declaration which gives the complete specification
2363: of the structure or union in situations in which the size
2364: of the structure or union is unnecessary.
2365: The size is unnecessary in two situations: when a
2366: pointer to a structure or union is being declared and
2367: when a \fBtypedef\fR name is declared to be a synonym
2368: for a structure or union.
2369: This, for example, allows the declaration of a pair
2370: of structures which contain pointers to each other.
2371: .PP
2372: The names of members and tags do not conflict
2373: with each other or with ordinary variables.
2374: A particular name may not be used twice
2375: in the same structure,
2376: but the same name may be used in several different structures in the same scope.
2377: .PP
2378: A simple but important example of a structure declaration is
2379: the following binary tree structure:
2380: .DS
2381: \fBstruct tnode
2382: {
2383: char tword[20];
2384: int count;
2385: struct tnode \(**left;
2386: struct tnode \(**right;
2387: };\fR
2388: .DE
2389: .LP
2390: which contains an array of 20 characters, an integer, and two pointers
2391: to similar structures.
2392: Once this declaration has been given, the
2393: declaration
2394: .DS
2395: \fBstruct tnode s, \(**sp;\fR
2396: .DE
2397: .LP
2398: declares
2399: .B
2400: s
2401: .R
2402: to be a structure of the given sort
2403: and
2404: .B
2405: sp
2406: .R
2407: to be a pointer to a structure
2408: of the given sort.
2409: With these declarations, the expression
2410: .DS
2411: \fBsp->count\fR
2412: .DE
2413: .LP
2414: refers to the
2415: .B
2416: count
2417: .R
2418: field of the structure to which
2419: .B
2420: sp
2421: .R
2422: points;
2423: .DS
2424: \fBs.left\fR
2425: .DE
2426: .LP
2427: refers to the left subtree pointer
2428: of the structure
2429: \fBs\fR;
2430: and
2431: .DS
2432: \fBs.right->tword[0]\fR
2433: .DE
2434: .LP
2435: refers to the first character of the
2436: .B
2437: tword
2438: .R
2439: member of the right subtree of
2440: .B
2441: s\fR.
2442: .R
2443: .PP
2444: .NH 2
2445: Enumeration Declarations
2446: .PP
2447: Enumeration variables and constants have integral type.
2448: .DS
2449: \fIenum-specifier:\fB
2450: enum\fI { enum-list \fR}\fB
2451: enum \fIidentifier { enum-list \fR}\fB
2452: enum \fIidentifier
2453: .sp
2454: enum-list:
2455: enumerator
2456: enum-list , enumerator
2457: .sp
2458: enumerator:
2459: identifier
2460: identifier = constant-expression\fR
2461: .DE
2462: .PP
2463: The identifiers in an enum-list are declared as constants
2464: and may appear wherever constants are required.
2465: If no enumerators with
2466: .B
2467: =
2468: .R
2469: appear, then the values of the
2470: corresponding constants begin at 0 and increase by 1 as the declaration is
2471: read from left to right.
2472: An enumerator with
2473: .B
2474: =
2475: .R
2476: gives the associated identifier the value
2477: indicated; subsequent identifiers continue the progression from the assigned value.
2478: .PP
2479: The names of enumerators in the same scope must all be distinct
2480: from each other and from those of ordinary variables.
2481: .PP
2482: The role of the identifier in the enum-specifier
2483: is entirely analogous to that of the structure tag
2484: in a struct-specifier; it names a particular enumeration.
2485: For example,
2486: .DS L
2487: \fBenum color { chartreuse, burgundy, claret=20, winedark };
2488: \&...
2489: enum color \(\(**\(**cp, col;
2490: \&...
2491: col = claret;
2492: cp = &col;
2493: \&...
2494: if (\(\(**\(**cp == burgundy) ...\fR
2495: .DE
2496: .LP
2497: makes
2498: .B
2499: color
2500: .R
2501: the enumeration-tag of a type describing various colors,
2502: and then declares
2503: .B
2504: cp
2505: .R
2506: as a pointer to an object of that type,
2507: and
2508: .B
2509: col
2510: .R
2511: as an object of that type.
2512: The possible values are drawn from the set {0,1,20,21}.
2513: .NH 2
2514: Initialization
2515: .PP
2516: A declarator may specify an initial value for the
2517: identifier being declared.
2518: The initializer is preceded by
2519: .B
2520: =
2521: .R
2522: and
2523: consists of an expression or a list of values nested in braces.
2524: .DS
2525: \fIinitializer:
2526: = expression
2527: = { initializer-list }
2528: = { initializer-list , }
2529: .DE
2530: .DS
2531: \fIinitializer-list:
2532: expression
2533: initializer-list , initializer-list\fR
2534: { \fIinitializer-list \fR}
2535: { \fIinitializer-list\fR , }
2536: .DE
2537: .PP
2538: All the expressions in an initializer
2539: for a static or external variable must be constant
2540: expressions, which are described in ``CONSTANT EXPRESSIONS'',
2541: or expressions which reduce to the address of a previously
2542: declared variable, possibly offset by a constant expression.
2543: Automatic or register variables may be initialized by arbitrary
2544: expressions involving constants and previously declared variables and functions.
2545: .PP
2546: Static and external variables that are not initialized are
2547: guaranteed to start off as zero.
2548: Automatic and register variables that are not initialized
2549: are guaranteed to start off as garbage.
2550: .PP
2551: When an initializer applies to a
2552: .I
2553: scalar
2554: .R
2555: (a pointer or an object of arithmetic type),
2556: it consists of a single expression, perhaps in braces.
2557: The initial value of the object is taken from
2558: the expression; the same conversions as for assignment are performed.
2559: .PP
2560: When the declared variable is an
2561: .I
2562: aggregate
2563: .R
2564: (a structure or array),
2565: the initializer consists of a brace-enclosed, comma-separated list of
2566: initializers for the members of the aggregate
2567: written in increasing subscript or member order.
2568: If the aggregate contains subaggregates, this rule
2569: applies recursively to the members of the aggregate.
2570: If there are fewer initializers in the list than there are members of the aggregate,
2571: then the aggregate is padded with zeros.
2572: It is not permitted to initialize unions or automatic aggregates.
2573: .PP
2574: Braces may in some cases be omitted.
2575: If the initializer begins with a left brace, then
2576: the succeeding comma-separated list of initializers initializes
2577: the members of the aggregate;
2578: it is erroneous for there to be more initializers than members.
2579: If, however, the initializer does not begin with a left brace,
2580: then only enough elements from the list are taken to account
2581: for the members of the aggregate; any remaining members
2582: are left to initialize the next member of the aggregate of which
2583: the current aggregate is a part.
2584: .PP
2585: A final abbreviation allows a
2586: .B
2587: char
2588: .R
2589: array to be initialized by a string.
2590: In this case successive characters of the string
2591: initialize the members of the array.
2592: .PP
2593: For example,
2594: .DS
2595: \fBint x[] = { 1, 3, 5 };\fR
2596: .DE
2597: .LP
2598: declares and initializes
2599: .B
2600: x
2601: .R
2602: as a one-dimensional array which has three members, since no size was specified
2603: and there are three initializers.
2604: .DS
2605: \fBfloat y[4][3] =
2606: {
2607: { 1, 3, 5 },
2608: { 2, 4, 6 },
2609: { 3, 5, 7 },
2610: };\fR
2611: .DE
2612: .LP
2613: is a completely-bracketed initialization:
2614: 1, 3, and 5 initialize the first row of
2615: the array
2616: \fBy[0]\fR,
2617: namely
2618: \fBy[0][0]\fR,
2619: \fBy[0][1]\fR,
2620: and
2621: .B
2622: y[0][2]\fR.
2623: .R
2624: Likewise, the next two lines initialize
2625: .B
2626: y[1]
2627: .R
2628: and
2629: .B
2630: y[2]\fR.
2631: .R
2632: The initializer ends early and therefore
2633: .B
2634: y[3]
2635: .R
2636: is initialized with 0.
2637: Precisely, the same effect could have been achieved by
2638: .DS
2639: \fBfloat y[4][3] =
2640: {
2641: 1, 3, 5, 2, 4, 6, 3, 5, 7
2642: };\fR
2643: .DE
2644: .PP
2645: The initializer for
2646: .B
2647: y
2648: .R
2649: begins with a left brace but that for
2650: .B
2651: y[0]
2652: .R
2653: does not;
2654: therefore, three elements from the list are used.
2655: Likewise, the next three are taken successively for
2656: .B
2657: y[1]
2658: .R
2659: and
2660: .B
2661: y[2]\fR.
2662: .R
2663: Also,
2664: .DS
2665: \fBfloat y[4][3] =
2666: {
2667: { 1 }, { 2 }, { 3 }, { 4 }
2668: };\fR
2669: .DE
2670: .LP
2671: initializes the first column of
2672: .B
2673: y
2674: .R
2675: (regarded as a two-dimensional array)
2676: and leaves the rest 0.
2677: .PP
2678: Finally,
2679: .DS
2680: \fBchar msg[] = "Syntax error on line %s\en";\fR
2681: .DE
2682: .LP
2683: shows a character array whose members are initialized
2684: with a string.
2685: .NH 2
2686: Type Names
2687: .PP
2688: In two contexts (to specify type conversions explicitly
2689: by means of a cast
2690: and as an argument of
2691: \fBsizeof\fR),
2692: it is desired to supply the name of a data type.
2693: This is accomplished using a ``type name'', which in essence
2694: is a declaration for an object of that type which omits the name of
2695: the object.
2696: .DS
2697: \fItype-name:
2698: type-specifier abstract-declarator
2699: .DE
2700: .DS
2701: \fIabstract-declarator:
2702: empty
2703: ( abstract-declarator )
2704: \(** abstract-declarator
2705: abstract-declarator ()
2706: abstract-declarator\fR\^ [ \fIconstant-expression\v'0.5'\s-2opt\s0\v'-0.5' \fR\^]
2707: .DE
2708: .PP
2709: To avoid ambiguity,
2710: in the construction
2711: .DS
2712: \fI( abstract-declarator \fR)
2713: .DE
2714: .LP
2715: the
2716: abstract-declarator
2717: is required to be nonempty.
2718: Under this restriction,
2719: it is possible to identify uniquely the location in the abstract-declarator
2720: where the identifier would appear if the construction were a declarator
2721: in a declaration.
2722: The named type is then the same as the type of the
2723: hypothetical identifier.
2724: For example,
2725: .DS
2726: \fBint
2727: int \(**
2728: int \(**[3]
2729: int (\(**)[3]
2730: int \(**()
2731: int (\(**)()
2732: int (\(**[3])()\fR
2733: .DE
2734: .LP
2735: name respectively the types ``integer,'' ``pointer to integer,''
2736: ``array of three pointers to integers,''
2737: ``pointer to an array of three integers,''
2738: ``function returning pointer to integer,''
2739: ``pointer to function returning an integer,''
2740: and ``array of three pointers to functions returning an integer.''
2741: .NH 2
2742: Typedef
2743: .PP
2744: Declarations whose ``storage class'' is
2745: .B
2746: typedef
2747: .R
2748: do not define storage but instead
2749: define identifiers which can be used later
2750: as if they were type keywords naming fundamental
2751: or derived types.
2752: .DS
2753: \fItypedef-name:\fR
2754: \fIidentifier\fR
2755: .DE
2756: .PP
2757: Within the scope of a declaration involving
2758: \fBtypedef\fR,
2759: each identifier appearing as part of
2760: any declarator therein becomes syntactically
2761: equivalent to the type keyword
2762: naming the type
2763: associated with the identifier
2764: in the way described in ``Meaning of Declarators.''
2765: For example,
2766: after
2767: .DS
2768: \fBtypedef int MILES, \(**KLICKSP;
2769: typedef struct { double re, im; } complex;\fR
2770: .DE
2771: .LP
2772: the constructions
2773: .DS
2774: \fBMILES distance;
2775: extern KLICKSP metricp;
2776: complex z, \(**zp;\fR
2777: .DE
2778: .LP
2779: are all legal declarations; the type of
2780: .B
2781: distance
2782: .R
2783: is
2784: \fBint\fR,
2785: that of
2786: .B
2787: metricp
2788: .R
2789: is ``pointer to \fBint\fR, ''
2790: and that of
2791: .B
2792: z
2793: .R
2794: is the specified structure.
2795: The
2796: .B
2797: zp
2798: .R
2799: is a pointer to such a structure.
2800: .PP
2801: The
2802: .B
2803: typedef
2804: .R
2805: does not introduce brand-new types, only synonyms for
2806: types which could be specified in another way.
2807: Thus
2808: in the example above
2809: .B
2810: distance
2811: .R
2812: is considered to have exactly the same type as
2813: any other
2814: .B
2815: int
2816: .R
2817: object.
2818: .NH 1
2819: Statements
2820: .PP
2821: Except as indicated, statements are executed in sequence.
2822: .NH 2
2823: Expression Statement
2824: .PP
2825: Most statements are expression statements, which have
2826: the form
2827: .DS
2828: \fIexpression \fR;
2829: .DE
2830: .PP
2831: Usually expression statements are assignments or function
2832: calls.
2833: .NH 2
2834: Compound Statement or Block
2835: .PP
2836: So that several statements can be used where one is expected,
2837: the compound statement (also, and equivalently, called ``block'') is provided:
2838: .DS
2839: \fIcompound-statement:
2840: { declaration-list\v'0.5'\s-2opt\s0\v'-0.5' statement-list\v'0.5'\s-2opt\s0\v'-0.5' }
2841: .DE
2842: .DS
2843: \fIdeclaration-list:
2844: declaration
2845: declaration declaration-list
2846: .DE
2847: .DS
2848: \fIstatement-list:
2849: statement
2850: statement statement-list\fR
2851: .DE
2852: .PP
2853: If any of the identifiers
2854: in the declaration-list were previously declared,
2855: the outer declaration is pushed down for the duration of the block,
2856: after which it resumes its force.
2857: .PP
2858: Any initializations of
2859: .B
2860: auto
2861: .R
2862: or
2863: .B
2864: register
2865: .R
2866: variables are performed each time the block is entered at the top.
2867: It is currently possible
2868: (but a bad practice)
2869: to transfer into a block;
2870: in that case the initializations are not performed.
2871: Initializations of
2872: .B
2873: static
2874: .R
2875: variables are performed only once when the program
2876: begins execution.
2877: Inside a block,
2878: .B
2879: extern
2880: .R
2881: declarations do not reserve storage
2882: so initialization is not permitted.
2883: .NH 2
2884: Conditional Statement
2885: .PP
2886: The two forms of the conditional statement are
2887: .DS
2888: \fBif\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
2889: \fBif\fR\^ ( \fIexpression\fR\^ ) \fIstatement \fBelse \fIstatement\fR\^
2890: .DE
2891: .PP
2892: In both cases, the expression is evaluated;
2893: and if it is nonzero, the first substatement
2894: is executed.
2895: In the second case, the second substatement is executed
2896: if the expression is 0.
2897: The ``else'' ambiguity is resolved by connecting
2898: an
2899: .B
2900: else
2901: .R
2902: with the last encountered
2903: \fBelse\fR-less
2904: .B
2905: if\fR.
2906: .R
2907: .NH 2
2908: While Statement
2909: .PP
2910: The
2911: .B
2912: while
2913: .R
2914: statement has the form
2915: .DS
2916: \fBwhile\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
2917: .DE
2918: .PP
2919: The substatement is executed repeatedly
2920: so long as the value of the
2921: expression remains nonzero.
2922: The test takes place before each execution of the
2923: statement.
2924: .NH 2
2925: Do Statement
2926: .PP
2927: The
2928: .B
2929: do
2930: .R
2931: statement has the form
2932: .DS
2933: \fBdo \fIstatement \fBwhile\fR\^ ( \fIexpression \fR\^) ;
2934: .DE
2935: .PP
2936: The substatement is executed repeatedly until
2937: the value of the expression becomes 0.
2938: The test takes place after each execution of the
2939: statement.
2940: .NH 2
2941: For Statement
2942: .PP
2943: The
2944: .B
2945: for
2946: .R
2947: statement has the form:
2948: .DS
2949: \fBfor\fI ( exp-1\v'0.5'\s-2opt\s0\v'-0.5' ; exp-2\v'0.5'\s-2opt\s0\v'-0.5' ; exp-3\v'0.5'\s-2opt\s0\v'-0.5' ) statement\fR
2950: .DE
2951: .PP
2952: .sp
2953: Except for the behavior of \fBcontinue\fR,
2954: this statement is equivalent to
2955: .DS
2956: \fIexp-1 \fR;
2957: \fBwhile\fR\^ ( \fIexp-2\ ) \fR\^
2958: {
2959: \fIstatement
2960: exp-3 ;\fR
2961: }
2962: .DE
2963: .PP
2964: Thus the first expression specifies initialization
2965: for the loop; the second specifies
2966: a test, made before each iteration, such
2967: that the loop is exited when the expression becomes
2968: 0.
2969: The third expression often specifies an incrementing
2970: that is performed after each iteration.
2971: .PP
2972: Any or all of the expressions may be dropped.
2973: A missing
2974: .I
2975: exp-2
2976: .R
2977: makes the
2978: implied
2979: .B
2980: while
2981: .R
2982: clause equivalent to
2983: \fBwhile(1)\fR;
2984: other missing expressions are simply
2985: dropped from the expansion above.
2986: .NH 2
2987: Switch Statement
2988: .PP
2989: The
2990: .B
2991: switch
2992: .R
2993: statement causes control to be transferred
2994: to one of several statements depending on
2995: the value of an expression.
2996: It has the form
2997: .DS
2998: \fBswitch\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
2999: .DE
3000: .PP
3001: The usual arithmetic conversion is performed on the
3002: expression, but the result must be
3003: .B
3004: int\fR.
3005: .R
3006: The statement is typically compound.
3007: Any statement within the statement
3008: may be labeled with one or more case prefixes
3009: as follows:
3010: .DS
3011: \fBcase \fIconstant-expression \fR:
3012: .DE
3013: .LP
3014: where the constant
3015: expression
3016: must be
3017: .B
3018: int\fR.
3019: .R
3020: No two of the case constants in the same switch
3021: may have the same value.
3022: Constant expressions are precisely defined in ``CONSTANT EXPRESSIONS.''
3023: .PP
3024: There may also be at most one statement prefix of the
3025: form
3026: .DS
3027: \fBdefault :\fR
3028: .DE
3029: .PP
3030: When the
3031: .B
3032: switch
3033: .R
3034: statement is executed, its expression
3035: is evaluated and compared with each case constant.
3036: If one of the case constants is
3037: equal to the value of the expression,
3038: control is passed to the statement
3039: following the matched case prefix.
3040: If no case constant matches the expression
3041: and if there is a
3042: \fBdefault\fR,
3043: prefix, control
3044: passes to the prefixed
3045: statement.
3046: If no case matches and if there is no
3047: \fBdefault\fR,
3048: then
3049: none of the statements in the
3050: switch is executed.
3051: .PP
3052: The prefixes
3053: .B
3054: case
3055: .R
3056: and
3057: .B
3058: default
3059: .R
3060: do not alter the flow of control,
3061: which continues unimpeded across such prefixes.
3062: To exit from a switch, see
3063: ``Break Statement.''
3064: .PP
3065: Usually, the statement that is the subject of a switch is compound.
3066: Declarations may appear at the head of this
3067: statement,
3068: but
3069: initializations of automatic or register variables
3070: are ineffective.
3071: .NH 2
3072: Break Statement
3073: .PP
3074: The statement
3075: .DS
3076: \fBbreak ;\fR
3077: .DE
3078: .LP
3079: causes termination of the smallest enclosing
3080: \fBwhile\fR,
3081: \fBdo\fR,
3082: \fBfor\fR,
3083: or
3084: \fBswitch\fR
3085: statement;
3086: control passes to the
3087: statement following the terminated statement.
3088: .NH 2
3089: Continue Statement
3090: .PP
3091: The statement
3092: .DS
3093: \fBcontinue ;\fR
3094: .DE
3095: .LP
3096: causes control to pass to the loop-continuation portion of the
3097: smallest enclosing
3098: \fBwhile\fR,
3099: \fBdo\fR,
3100: or
3101: \fBfor\fR
3102: statement; that is to the end of the loop.
3103: More precisely, in each of the statements
3104: .DS
3105: .TS
3106: lw(2i) lw(2i) lw(2i).
3107: \fBwhile (\|.\|.\|.\|) { do { for (\|.\|.\|.\|) {\fR
3108: \fIstatement ; statement ; statement ;\fR
3109: \fBcontin: ; contin: ; contin: ;
3110: } } while (...); }\fR
3111: .TE
3112: .DE
3113: .LP
3114: a
3115: .B
3116: continue
3117: .R
3118: is equivalent to
3119: .B
3120: goto\ contin\fR.
3121: .R
3122: (Following the
3123: .B
3124: contin:
3125: .R
3126: is a null statement, see ``Null Statement''.)
3127: .NH 2
3128: Return Statement
3129: .PP
3130: A function returns to its caller by means of
3131: the
3132: .B
3133: return
3134: .R
3135: statement which has one of the
3136: forms
3137: .DS
3138: \fBreturn ;
3139: return \fIexpression \fR;
3140: .DE
3141: .PP
3142: In the first case, the returned value is undefined.
3143: In the second case, the value of the expression
3144: is returned to the caller
3145: of the function.
3146: If required, the expression is converted,
3147: as if by assignment, to the type of
3148: function in which it appears.
3149: Flowing off the end of a function is
3150: equivalent to a return with no returned value.
3151: The expression may be parenthesized.
3152: .NH 2
3153: Goto Statement
3154: .PP
3155: Control may be transferred unconditionally by means of
3156: the statement
3157: .DS
3158: \fBgoto \fIidentifier \fR;
3159: .DE
3160: .PP
3161: The identifier must be a label
3162: (see ``Labeled Statement'')
3163: located in the current function.
3164: .NH 2
3165: Labeled Statement
3166: .PP
3167: Any statement may be preceded by
3168: label prefixes of the form
3169: .DS
3170: \fIidentifier \fR:
3171: .DE
3172: .LP
3173: which serve to declare the identifier
3174: as a label.
3175: The only use of a label is as a target of a
3176: .B
3177: goto\fR.
3178: .R
3179: The scope of a label is the current function,
3180: excluding any subblocks in which the same identifier has been redeclared.
3181: See ``SCOPE RULES.''
3182: .NH 2
3183: Null Statement
3184: .PP
3185: The null statement has the form
3186: .DS
3187: \fB;\fR
3188: .DE
3189: .PP
3190: A null statement is useful to carry a label just before the
3191: .B
3192: }
3193: .R
3194: of a compound statement or to supply a null
3195: body to a looping statement such as
3196: .B
3197: while\fR.
3198: .R
3199: .NH 1
3200: External Definitions
3201: .PP
3202: A C program consists of a sequence of external definitions.
3203: An external definition declares an identifier to
3204: have storage class
3205: .B
3206: extern
3207: .R
3208: (by default)
3209: or perhaps
3210: \fBstatic\fR,
3211: and
3212: a specified type.
3213: The type-specifier (see ``Type Specifiers'' in
3214: ``DECLARATIONS'') may also be empty, in which
3215: case the type is taken to be
3216: .B
3217: int\fR.
3218: .R
3219: The scope of external definitions persists to the end
3220: of the file in which they are declared just as the effect
3221: of declarations persists to the end of a block.
3222: The syntax of external definitions is the same
3223: as that of all declarations except that
3224: only at this level may the code for functions be given.
3225: .NH 2
3226: External Function Definitions
3227: .PP
3228: Function definitions have the form
3229: .DS
3230: \fIfunction-definition:
3231: decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5' function-declarator function-body\fR
3232: .DE
3233: .PP
3234: The only sc-specifiers
3235: allowed
3236: among the decl-specifiers
3237: are
3238: .B
3239: extern
3240: .R
3241: or
3242: \fBstatic\fR;
3243: see ``Scope of Externals'' in
3244: ``SCOPE RULES'' for the distinction between them.
3245: A function declarator is similar to a declarator
3246: for a ``function returning .\|.\|.\|'' except that
3247: it lists the formal parameters of
3248: the function being defined.
3249: .DS
3250: \fIfunction-declarator:
3251: declarator ( parameter-list\v'0.5'\s-2opt\s0\v'-0.5' )
3252: .DE
3253: .DS
3254: \fIparameter-list:
3255: identifier
3256: identifier , parameter-list\fR
3257: .DE
3258: .PP
3259: The function-body
3260: has the form
3261: .DS
3262: \fIfunction-body:
3263: declaration-list\v'0.5'\s-2opt\s0\v'-0.5' compound-statement\fR
3264: .DE
3265: .PP
3266: The identifiers in the parameter list, and only those identifiers,
3267: may be declared in the declaration list.
3268: Any identifiers whose type is not given are taken to be
3269: .B
3270: int\fR.
3271: .R
3272: The only storage class which may be specified is
3273: \fBregister\fR;
3274: if it is specified, the corresponding actual parameter
3275: will be copied, if possible, into a register
3276: at the outset of the function.
3277: .PP
3278: A simple example of a complete function definition is
3279: .DS
3280: \fBint max(a, b, c)
3281: int a, b, c;
3282: {
3283: int m;
3284: .sp
3285: m = (a > b) ? a : b;
3286: return((m > c) ? m : c);
3287: }\fR
3288: .DE
3289: .PP
3290: Here
3291: .B
3292: int
3293: .R
3294: is the type-specifier;
3295: .B
3296: max(a,\ b,\ c)
3297: .R
3298: is the function-declarator;
3299: .B
3300: int\ a,\ b,\ c;
3301: .R
3302: is the declaration-list for
3303: the formal
3304: parameters;
3305: \fB{\ ...\ }\fR
3306: is the
3307: block giving the code for the statement.
3308: .PP
3309: The C program converts all
3310: .B
3311: float
3312: .R
3313: actual parameters
3314: to
3315: \fBdouble\fR,
3316: so formal parameters declared
3317: .B
3318: float
3319: .R
3320: have their declaration adjusted to read
3321: .B
3322: double\fR.
3323: .R
3324: All \fBchar\fR and \fBshort\fR formal parameter
3325: declarations are similarly adjusted
3326: to read \fBint\fR.
3327: Also, since a reference to an array in any context
3328: (in particular as an actual parameter)
3329: is taken to mean
3330: a pointer to the first element of the array,
3331: declarations of formal parameters declared ``array of .\|.\|.\|''
3332: are adjusted to read ``pointer to .\|.\|.\|.''
3333: .NH 2
3334: External Data Definitions
3335: .PP
3336: An external data definition has the form
3337: .DS
3338: \fIdata-definition:
3339: declaration\fR
3340: .DE
3341: .PP
3342: The storage class of such data may be
3343: .B
3344: extern
3345: .R
3346: (which is the default)
3347: or
3348: .B
3349: static
3350: .R
3351: but not
3352: .B
3353: auto
3354: .R
3355: or
3356: \fBregister\fR.
3357: .NH 1
3358: Scope Rules
3359: .PP
3360: A C program need not all
3361: be compiled at the same time. The source text of the
3362: program
3363: may be kept in several files, and precompiled
3364: routines may be loaded from
3365: libraries.
3366: Communication among the functions of a program
3367: may be carried out both through explicit calls
3368: and through manipulation of external data.
3369: .PP
3370: Therefore, there are two kinds of scopes to consider:
3371: first, what may be called the
3372: .UL lexical
3373: .UL scope
3374: of an identifier, which is essentially the
3375: region of a program during which it may
3376: be used without drawing ``undefined identifier''
3377: diagnostics;
3378: and second, the scope
3379: associated with external identifiers,
3380: which is characterized by the rule
3381: that references to the same external
3382: identifier are references to the same object.
3383: .NH 2
3384: Lexical Scope
3385: .PP
3386: The lexical scope of identifiers declared in external definitions
3387: persists from the definition through
3388: the end of the source file
3389: in which they appear.
3390: The lexical scope of identifiers which are formal parameters
3391: persists through the function with which they are
3392: associated.
3393: The lexical scope of identifiers declared at the head of a block
3394: persists until the end of the block.
3395: The lexical scope of labels is the whole of the
3396: function in which they appear.
3397: .PP
3398: In all cases, however,
3399: if an identifier is explicitly declared at the head of a block,
3400: including the block constituting a function,
3401: any declaration of that identifier outside the block
3402: is suspended until the end of the block.
3403: .PP
3404: Remember also (see ``Structure, Union, and Enumeration Declarations'' in
3405: ``DECLARATIONS'') that tags, identifiers associated with
3406: ordinary variables,
3407: and identities associated with structure and union members
3408: form three disjoint classes
3409: which do not conflict.
3410: Members and tags follow the same scope rules
3411: as other identifiers.
3412: The \fBenum\fR constants are in the same
3413: class as ordinary variables and follow the same scope rules.
3414: The
3415: .B
3416: typedef
3417: .R
3418: names are in the same class as ordinary identifiers.
3419: They may be redeclared in inner blocks, but an explicit
3420: type must be given in the inner declaration:
3421: .DS
3422: \fBtypedef float distance;
3423: \&...
3424: {
3425: auto int distance;
3426: ...\fR
3427: }
3428: .DE
3429: .PP
3430: The
3431: .B
3432: int
3433: .R
3434: must be present in the second declaration,
3435: or it would be taken to be
3436: a declaration with no declarators and type
3437: .B
3438: distance\fR.
3439: .R
3440: .NH 2
3441: Scope of Externals
3442: .PP
3443: If a function refers to an identifier declared to be
3444: \fBextern\fR,
3445: then somewhere among the files or libraries
3446: constituting the complete program
3447: there must be at least one external definition
3448: for the identifier.
3449: All functions in a given program which refer to the same
3450: external identifier refer to the same object,
3451: so care must be taken that the type and size
3452: specified in the definition
3453: are compatible with those specified
3454: by each function which references the data.
3455: .PP
3456: It is illegal to explicitly initialize any external
3457: identifier more than once in the set of files and libraries
3458: comprising a multi-file program.
3459: It is legal to have more than one data definition
3460: for any external non-function identifier;
3461: explicit use of \fBextern\fR does not
3462: change the meaning of an external declaration.
3463: .PP
3464: In restricted environments, the use of the \fBextern\fR
3465: storage class takes on an additional meaning.
3466: In these environments, the explicit appearance of the
3467: \fBextern\fR keyword in external data declarations of
3468: identities without initialization indicates that
3469: the storage for the identifiers is allocated elsewhere,
3470: either in this file or another file.
3471: It is required that there be exactly one definition of
3472: each external identifier (without \fBextern\fR)
3473: in the set of files and libraries
3474: comprising a mult-file program.
3475: .PP
3476: Identifiers declared
3477: .B
3478: static
3479: .R
3480: at the top level in external definitions
3481: are not visible in other files.
3482: Functions may be declared
3483: .B
3484: static\fR.
3485: .R
3486: .nr Hu 1
3487: .NH 1
3488: Compiler Control Lines
3489: .PP
3490: The C compiler contains a preprocessor capable
3491: of macro substitution, conditional compilation,
3492: and inclusion of named files.
3493: Lines beginning with
3494: .B
3495: #
3496: .R
3497: communicate
3498: with this preprocessor.
3499: There may be any number of blanks and horizontal tabs
3500: between the \fB#\fR and the directive.
3501: These lines have syntax independent of the rest of the language;
3502: they may appear anywhere and have effect which lasts (independent of
3503: scope) until the end of the source program file.
3504: .nr Hu 1
3505: .NH 2
3506: Token Replacement
3507: .PP
3508: A compiler-control line of the form
3509: .DS
3510: \fB#define \fIidentifier token-string\v'0.5'\s-2opt\s0\v'-0.5'\fR
3511: .DE
3512: .LP
3513: causes the preprocessor to replace subsequent instances
3514: of the identifier with the given string of tokens.
3515: Semicolons in or at the end of the token-string are part of that string.
3516: A line of the form
3517: .DS
3518: \fB#define \fIidentifier(identifier, ... )token-string\v'0.5'\s-2opt\s0\v'-0.5'\fR
3519: .DE
3520: .LP
3521: where there is no space between the first identifier
3522: and the
3523: \fB(\fR,
3524: is a macro definition with arguments.
3525: There may be zero or more formal parameters.
3526: Subsequent instances of the first identifier followed
3527: by a
3528: \fB(\fR,
3529: a sequence of tokens delimited by commas, and a
3530: \fB)\fR
3531: are replaced
3532: by the token string in the definition.
3533: Each occurrence of an identifier mentioned in the formal parameter list
3534: of the definition is replaced by the corresponding token string from the call.
3535: The actual arguments in the call are token strings separated by commas;
3536: however, commas in quoted strings or protected by
3537: parentheses do not separate arguments.
3538: The number of formal and actual parameters must be the same.
3539: Strings and character constants in the token-string are scanned
3540: for formal parameters, but
3541: strings and character constants in the rest of the program are
3542: not scanned for defined identifiers
3543: to replacement.
3544: .PP
3545: In both forms the replacement string is rescanned for more
3546: defined identifiers.
3547: In both forms
3548: a long definition may be continued on another line
3549: by writing
3550: .B
3551: \e
3552: .R
3553: at the end of the line to be continued.
3554: .PP
3555: This facility is most valuable for definition of ``manifest constants,''
3556: as in
3557: .DS
3558: \fB#define TABSIZE 100
3559: .sp
3560: int table\|[\|TABSIZE\|]\|;\fR
3561: .DE
3562: .PP
3563: A control line of the form
3564: .DS
3565: \fB#undef \fIidentifier\fR
3566: .DE
3567: .LP
3568: causes the
3569: identifier's preprocessor definition (if any) to be forgotten.
3570: .PP
3571: If a \fB#define\fRd identifier is the subject of a subsequent
3572: \fB#define\fR with no intervening \fB#undef\fR, then
3573: the two token-strings are compared textually.
3574: If the two token-strings are not identical
3575: (all white space is considered as equivalent), then
3576: the identifier is considered to be redefined.
3577: .nr Hu 1
3578: .NH 2
3579: File Inclusion
3580: .PP
3581: A compiler control line of
3582: the form
3583: .DS
3584: \fB#include\fI "filename\|\fR"
3585: .DE
3586: .LP
3587: causes the replacement of that
3588: line by the entire contents of the file
3589: .I
3590: filename\fR.
3591: .R
3592: The named file is searched for first in the directory
3593: of the file containing the \fB#include\fR,
3594: and then in a sequence of specified or standard places.
3595: Alternatively, a control line of the form
3596: .DS
3597: \fB#include\fI <filename\|\fR>
3598: .DE
3599: .LP
3600: searches only the specified or standard places
3601: and not the directory of the \fB#include\fR.
3602: (How the places are specified is not part of the language.)
3603: .PP
3604: \fB#include\fRs
3605: may be nested.
3606: .nr Hu 1
3607: .NH 2
3608: Conditional Compilation
3609: .PP
3610: A compiler control line of the form
3611: .DS
3612: \fB#if \fIrestricted-constant-expression\fR
3613: .DE
3614: .LP
3615: checks whether the restricted-constant expression evaluates to nonzero.
3616: (Constant expressions are discussed in ``CONSTANT EXPRESSIONS'';
3617: the following additional restrictions apply here:
3618: the constant expression may not contain
3619: .B
3620: sizeof
3621: .R
3622: casts, or an enumeration constant.)
3623: .PP
3624: A restricted constant expression may also contain the
3625: additional unary expression
3626: .PP
3627: \fBdefined \fIidentifier\fR
3628: .LP
3629: or
3630: .PP
3631: \fBdefined( \fIidentifier )\fR
3632: .LP
3633: which evaluates to one if the identifier is currently
3634: defined in the preprocessor and zero if it is not.
3635: .PP
3636: All currently defined identifiers in restricted-constant-expressions
3637: are replaced by their token-strings (except those identifiers
3638: modified by \fBdefined\fR) just as in normal text.
3639: The restricted constant expression will be evaluated only
3640: after all expressions have finished.
3641: During this evaluation, all undefined (to the procedure)
3642: identifiers evaluate to zero.
3643: .PP
3644: A control line of the form
3645: .DS
3646: \fB#ifdef \fIidentifier\fR
3647: .DE
3648: .LP
3649: checks whether the identifier is currently defined
3650: in the preprocessor; i.e., whether it has been the
3651: subject of a
3652: .B
3653: #define
3654: .R
3655: control line.
3656: It is equivalent to \fB#ifdef(\fIidentifier\fB)\fR.
3657: A control line of the form
3658: .DS
3659: \fB#ifndef \fIidentifier\fR
3660: .DE
3661: .LP
3662: checks whether the identifier is currently undefined
3663: in the preprocessor.
3664: It is equivalent to
3665: .DS
3666: \fB#if !\|defined(\fIidentifier\fB)\fR.
3667: .DE
3668: .PP
3669: All three forms are followed by an arbitrary number of lines,
3670: possibly containing a control line
3671: .DS
3672: \fB#else\fR
3673: .DE
3674: .LP
3675: and then by a control line
3676: .DS
3677: \fB#endif\fR
3678: .DE
3679: .PP
3680: If the checked condition is true,
3681: then any lines
3682: between
3683: .B
3684: #else
3685: .R
3686: and
3687: .B
3688: #endif
3689: .R
3690: are ignored.
3691: If the checked condition is false, then any lines between
3692: the test and a
3693: .B
3694: #else
3695: .R
3696: or, lacking a
3697: \fB#else\fR,
3698: the
3699: .B
3700: #endif
3701: .R
3702: are ignored.
3703: .PP
3704: These constructions may be nested.
3705: .nr Hu 1
3706: .NH 2
3707: Line Control
3708: .PP
3709: For the benefit of other preprocessors which generate C programs,
3710: a line of the form
3711: .DS
3712: \fB#line \fIconstant "filename\fR"
3713: .DE
3714: .LP
3715: causes the compiler to believe, for purposes of error
3716: diagnostics,
3717: that the line number of the next source line is given by the constant and the current input
3718: file is named by "\fIfilename\fR".
3719: If "\fIfilename\fR" is absent, the remembered file name does not change.
3720: .nr Hu 1
3721: .NH 1
3722: Implicit Declarations
3723: .PP
3724: It is not always necessary to specify
3725: both the storage class and the type
3726: of identifiers in a declaration.
3727: The storage class is supplied by
3728: the context in external definitions
3729: and in declarations of formal parameters
3730: and structure members.
3731: In a declaration inside a function,
3732: if a storage class but no type
3733: is given, the identifier is assumed
3734: to be
3735: \fBint\fR;
3736: if a type but no storage class is indicated,
3737: the identifier is assumed to
3738: be
3739: .B
3740: auto\fR.
3741: .R
3742: An exception to the latter rule is made for
3743: functions because
3744: .B
3745: auto
3746: .R
3747: functions do not exist.
3748: If the type of an identifier is ``function returning .\|.\|.\|,''
3749: it is implicitly declared to be
3750: .B
3751: extern\fR.
3752: .R
3753: .PP
3754: In an expression, an identifier
3755: followed by
3756: .B
3757: (
3758: .R
3759: and not already declared
3760: is contextually
3761: declared to be ``function returning
3762: .B
3763: int\fR.''
3764: .nr Hu 1
3765: .NH 1
3766: Types Revisited
3767: .PP
3768: This part summarizes the operations
3769: which can be performed on objects of certain types.
3770: .nr Hu 1
3771: .NH 2
3772: Structures and Unions
3773: .PP
3774: Structures and unions may be assigned, passed as arguments to functions,
3775: and returned by functions.
3776: Other plausible operators, such as equality comparison
3777: and structure casts,
3778: are not implemented.
3779: .PP
3780: In a reference
3781: to a structure or union member, the
3782: name on the right
3783: of the \fB->\fR or the \fB.\fR
3784: must specify a member of the aggregate
3785: named or pointed to by the expression
3786: on the left.
3787: In general, a member of a union may not be inspected
3788: unless the value of the union has been assigned using that same member.
3789: However, one special guarantee is made by the language in order
3790: to simplify the use of unions:
3791: if a union contains several structures that share a common initial sequence
3792: and if the union currently contains one of these structures,
3793: it is permitted to inspect the common initial part of any of
3794: the contained structures.
3795: For example, the following is a legal fragment:
3796: .DS
3797: \fBunion
3798: {
3799: struct
3800: {
3801: int type;
3802: } n;
3803: struct
3804: {
3805: int type;
3806: int intnode;
3807: } ni;
3808: struct
3809: {
3810: int type;
3811: float floatnode;
3812: } nf;
3813: } u;
3814: \&...
3815: u.nf.type = FLOAT;
3816: u.nf.floatnode = 3.14;
3817: \&...
3818: if (u.n.type == FLOAT)
3819: ... sin(u.nf.floatnode) ...\fR
3820: .DE
3821: .PP
3822: .nr Hu 1
3823: .NH 2
3824: Functions
3825: .PP
3826: There are only two things that
3827: can be done with a function \fBm\fR,
3828: call it or take its address.
3829: If the name of a function appears in an
3830: expression not in the function-name position of a call,
3831: a pointer to the function is generated.
3832: Thus, to pass one function to another, one
3833: might say
3834: .DS
3835: \fBint f();
3836: \&...
3837: g(f);\fR
3838: .DE
3839: .PP
3840: .ne 8
3841: Then the definition of
3842: .B
3843: g
3844: .R
3845: might read
3846: .DS
3847: \fBg(funcp)
3848: int (\(**funcp)();
3849: {
3850: ...
3851: (\(**funcp)();
3852: ...
3853: }\fR
3854: .DE
3855: .PP
3856: Notice that
3857: .B
3858: f
3859: .R
3860: must be declared
3861: explicitly in the calling routine since its appearance
3862: in
3863: .B
3864: g(f)
3865: .R
3866: was not followed by
3867: .B
3868: (.
3869: .R
3870: .nr Hu 1
3871: .NH 2
3872: Arrays, Pointers, and Subscripting
3873: .PP
3874: Every time an identifier of array type appears
3875: in an expression, it is converted into a pointer
3876: to the first member of the array.
3877: Because of this conversion, arrays are not
3878: lvalues.
3879: By definition, the subscript operator
3880: .B
3881: []
3882: .R
3883: is interpreted
3884: in such a way that
3885: .B
3886: E1[E2]
3887: .R
3888: is identical to
3889: .B
3890: \(**((E1)\(plE2))\fR.
3891: .R
3892: Because of the conversion rules
3893: which apply to
3894: \fB\(pl\fR,
3895: if
3896: .B
3897: E1
3898: .R
3899: is an array and
3900: .B
3901: E2
3902: .R
3903: an integer,
3904: then
3905: .B
3906: E1[E2]
3907: .R
3908: refers to the
3909: .B
3910: E2-th
3911: .R
3912: member of
3913: .B
3914: E1\fR.
3915: .R
3916: Therefore,
3917: despite its asymmetric
3918: appearance, subscripting is a commutative operation.
3919: .PP
3920: A consistent rule is followed in the case of
3921: multidimensional arrays.
3922: If
3923: .B
3924: E
3925: .R
3926: is an
3927: \fIn\fR-dimensional
3928: array
3929: of rank
3930: i\(muj\(mu...\(muk,
3931: then
3932: .B
3933: E
3934: .R
3935: appearing in an expression is converted to
3936: a pointer to an (n-1)-dimensional
3937: array with rank
3938: j\(mu...\(muk.
3939: If the
3940: .B
3941: \(**
3942: .R
3943: operator, either explicitly
3944: or implicitly as a result of subscripting,
3945: is applied to this pointer,
3946: the result is the pointed-to (n-1)-dimensional array,
3947: which itself is immediately converted into a pointer.
3948: .PP
3949: For example, consider
3950: .DS
3951: \fBint x[3][5];\fR
3952: .DE
3953: .PP
3954: Here
3955: .B
3956: x
3957: .R
3958: is a 3\(mu5 array of integers.
3959: When
3960: .B
3961: x
3962: .R
3963: appears in an expression, it is converted
3964: to a pointer to (the first of three) 5-membered arrays of integers.
3965: In the expression
3966: \fBx[i]\fR,
3967: which is equivalent to
3968: \fB\(**(x\(pli)\fR,
3969: .B
3970: x
3971: .R
3972: is first converted to a pointer as described;
3973: then
3974: .B
3975: i
3976: .R
3977: is converted to the type of
3978: \fBx\fR,
3979: which involves multiplying
3980: .B
3981: i
3982: .R
3983: by the
3984: length the object to which the pointer points,
3985: namely 5-integer objects.
3986: The results are added and indirection applied to
3987: yield an array (of five integers) which in turn is converted to
3988: a pointer to the first of the integers.
3989: If there is another subscript, the same argument applies
3990: again; this time the result is an integer.
3991: .PP
3992: Arrays in C are stored
3993: row-wise (last subscript varies fastest)
3994: and the first subscript in the declaration helps determine
3995: the amount of storage consumed by an array.
3996: Arrays play no other part in subscript calculations.
3997: .nr Hu 1
3998: .NH 2
3999: Explicit Pointer Conversions
4000: .PP
4001: Certain conversions involving pointers are permitted
4002: but have implementation-dependent aspects.
4003: They are all specified by means of an explicit type-conversion
4004: operator, see ``Unary Operators'' under``EXPRESSIONS'' and
4005: ``Type Names''under ``DECLARATIONS.''
4006: .PP
4007: A pointer may be converted to any of the integral types large
4008: enough to hold it.
4009: Whether an
4010: .B
4011: int
4012: .R
4013: or
4014: .B
4015: long
4016: .R
4017: is required is machine dependent.
4018: The mapping function is also machine dependent but is intended
4019: to be unsurprising to those who know the addressing structure
4020: of the machine.
4021: Details for some particular machines are given below.
4022: .PP
4023: An object of integral type may be explicitly converted to a pointer.
4024: The mapping always carries an integer converted from a pointer back to the same pointer
4025: but is otherwise machine dependent.
4026: .PP
4027: A pointer to one type may be converted to a pointer to another type.
4028: The resulting pointer may cause addressing exceptions
4029: upon use if
4030: the subject pointer does not refer to an object suitably aligned in storage.
4031: It is guaranteed that
4032: a pointer to an object of a given size may be converted to a pointer to an object
4033: of a smaller size
4034: and back again without change.
4035: .PP
4036: For example,
4037: a storage-allocation routine
4038: might accept a size (in bytes)
4039: of an object to allocate, and return a
4040: .B
4041: char
4042: .R
4043: pointer;
4044: it might be used in this way.
4045: .DS
4046: \fBextern char \(**malloc();
4047: double \(**dp;
4048: .sp
4049: dp = (double \(**) malloc(sizeof(double));
4050: \(**dp = 22.0 / 7.0;\fR
4051: .DE
4052: .PP
4053: The
4054: .B
4055: alloc
4056: .R
4057: must ensure (in a machine-dependent way)
4058: that its return value is suitable for conversion to a pointer to
4059: \fBdouble\fR;
4060: then the
4061: .I
4062: use
4063: .R
4064: of the function is portable.
4065: .PP
4066: The pointer
4067: representation on the
4068: PDP-11
4069: corresponds to a 16-bit integer and
4070: measures bytes.
4071: The
4072: .B
4073: char\fR's
4074: have no alignment requirements; everything else must have an even address.
4075: .PP
4076: On the
4077: VAX-11,
4078: pointers are 32 bits long and measure bytes.
4079: Elementary objects are aligned on a boundary equal to their
4080: length, except that
4081: .B
4082: double
4083: .R
4084: quantities need be aligned only on even 4-byte boundaries.
4085: Aggregates are aligned on the strictest boundary required by
4086: any of their constituents.
4087: .PP
4088: The 3B 20 computer has 24-bit pointers placed into 32-bit quantities.
4089: Most objects are
4090: aligned on 4-byte boundaries. \fBShort\fRs are aligned in all cases on
4091: 2-byte boundaries. Arrays of characters, all structures,
4092: \fBint\fR\^s, \fBlong\fR\^s, \fBfloat\fR\^s, and \fBdouble\fR\^s are aligned on 4-byte
4093: boundries; but structure members may be packed tighter.
4094: .nr Hu 1
4095: .NH 2
4096: CONSTANT EXPRESSIONS
4097: .PP
4098: In several places C requires expressions that evaluate to
4099: a constant:
4100: after
4101: \fBcase\fR,
4102: as array bounds, and in initializers.
4103: In the first two cases, the expression can
4104: involve only integer constants, character constants,
4105: casts to integral types,
4106: enumeration constants,
4107: and
4108: .B
4109: sizeof
4110: .R
4111: expressions, possibly
4112: connected by the binary operators
4113: .ne 10
4114: .DS
4115: \(pl \(mi \(** / % & | ^ << >> == != < > <= >= && ||
4116: .DE
4117: .LP
4118: or by the unary operators
4119: .DS
4120: \(mi \s+2~\s0
4121: .DE
4122: .LP
4123: or by the ternary operator
4124: .DS
4125: ?:
4126: .DE
4127: .PP
4128: Parentheses can be used for grouping
4129: but not for function calls.
4130: .PP
4131: More latitude is permitted for initializers;
4132: besides constant expressions as discussed above,
4133: one can also use floating constants
4134: and arbitrary casts and
4135: can also apply the unary
4136: .B
4137: &
4138: .R
4139: operator to external or static objects
4140: and to external or static arrays subscripted
4141: with a constant expression.
4142: The unary
4143: .B
4144: &
4145: .R
4146: can also
4147: be applied implicitly
4148: by appearance of unsubscripted arrays and functions.
4149: The basic rule is that initializers must
4150: evaluate either to a constant or to the address
4151: of a previously declared external or static object plus or minus a constant.
4152: .nr Hu 1
4153: .NH 1
4154: Portability Considerations
4155: .PP
4156: Certain parts of C are inherently machine dependent.
4157: The following list of potential trouble spots
4158: is not meant to be all-inclusive
4159: but to point out the main ones.
4160: .PP
4161: Purely hardware issues like
4162: word size and the properties of floating point arithmetic and integer division
4163: have proven in practice to be not much of a problem.
4164: Other facets of the hardware are reflected
4165: in differing implementations.
4166: Some of these,
4167: particularly sign extension
4168: (converting a negative character into a negative integer)
4169: and the order in which bytes are placed in a word,
4170: are nuisances that must be carefully watched.
4171: Most of the others are only minor problems.
4172: .PP
4173: The number of
4174: .B
4175: register
4176: .R
4177: variables that can actually be placed in registers
4178: varies from machine to machine
4179: as does the set of valid types.
4180: Nonetheless, the compilers all do things properly for their own machine;
4181: excess or invalid
4182: .B
4183: register
4184: .R
4185: declarations are ignored.
4186: .PP
4187: Some difficulties arise only when
4188: dubious coding practices are used.
4189: It is exceedingly unwise to write programs
4190: that depend
4191: on any of these properties.
4192: .PP
4193: The order of evaluation of function arguments
4194: is not specified by the language.
4195: The order in which side effects take place
4196: is also unspecified.
4197: .PP
4198: Since character constants are really objects of type
4199: \fBint\fR,
4200: multicharacter character constants may be permitted.
4201: The specific implementation
4202: is very machine dependent
4203: because the order in which characters
4204: are assigned to a word
4205: varies from one machine to another.
4206: .PP
4207: Fields are assigned to words and characters to integers right to left
4208: on some machines
4209: and left to right on other machines.
4210: These differences are invisible to isolated programs
4211: that do not indulge in type punning (e.g.,
4212: by converting an
4213: .B
4214: int
4215: .R
4216: pointer to a
4217: .B
4218: char
4219: .R
4220: pointer and inspecting the pointed-to storage)
4221: but must be accounted for when conforming to externally-imposed
4222: storage layouts.
4223: .nr Hu 1
4224: .NH 1
4225: Syntax Summary
4226: .PP
4227: This summary of C syntax is intended more for aiding comprehension
4228: than as an exact statement of the language.
4229: .nr Hu 1
4230: .ne 18
4231: .NH 2
4232: Expressions
4233: .PP
4234: The basic expressions are:
4235: .tr ~~
4236: .DS
4237: \fIexpression:
4238: primary
4239: \(** expression\fR
4240: &\fIlvalue
4241: \(mi expression
4242: ! expression
4243: \s+2~\s0 expression
4244: \(pl\(pl lvalue
4245: \(mi\(milvalue
4246: lvalue \(pl\(pl
4247: lvalue \(mi\(mi
4248: \fBsizeof\fI expression
4249: \fBsizeof (\fItype-name\fB)\fI
4250: ( type-name ) expression
4251: expression binop expression
4252: expression ? expression : expression
4253: lvalue asgnop expression
4254: expression , expression
4255: .DE
4256: .DS
4257: \fIprimary:
4258: identifier
4259: constant
4260: string
4261: ( expression )
4262: primary ( expression-list\v'0.5'\s-2opt\s0\v'-0.5' )
4263: primary [ expression ]
4264: primary . identifier
4265: primary \(mi identifier
4266: .DE
4267: .DS
4268: \fIlvalue:
4269: identifier
4270: primary [ expression ]
4271: lvalue . identifier
4272: primary \(mi identifier
4273: \(** expression
4274: ( lvalue )\fR
4275: .DE
4276: .PP
4277: .PP
4278: The primary-expression operators
4279: .DS
4280: () [] . \(mi
4281: .tr ~~
4282: .DE
4283: .LP
4284: have highest priority and group left to right.
4285: The unary operators
4286: .DS
4287: \(** & \(mi ! \s+2~\s0 \(pl\(pl \(mi\(mi \fBsizeof\fI ( type-name \fR)
4288: .DE
4289: .LP
4290: have priority below the primary operators
4291: but higher than any binary operator
4292: and group right to left.
4293: Binary operators
4294: group left to right; they have priority
4295: decreasing
4296: as indicated below.
4297: .DS
4298: \fIbinop:\fR
4299: \(** / %
4300: \(pl \(mi
4301: >> <<
4302: < > <= >=
4303: == !=
4304: &
4305: ^
4306: |
4307: &&
4308: ||
4309: .DE
4310: The conditional operator groups right to left.
4311: .PP
4312: Assignment operators all have the same
4313: priority and all group right to left.
4314: .DS
4315: \fIasgnop:\fR
4316: = \(pl= \(mi= \(**= /= %= >>= <<= &= ^= |=
4317: .DE
4318: .PP
4319: The comma operator has the lowest priority and groups left to right.
4320: .nr Hu 1
4321: .NH 2
4322: Declarations
4323: .PP
4324: .DS
4325: \fIdeclaration:
4326: decl-specifiers init-declarator-list\v'0.5'\s-2opt\s0\v'-0.5' ;
4327: .DE
4328: .DS
4329: \fIdecl-specifiers:
4330: type-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
4331: sc-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
4332: .DE
4333: .DS
4334: \fIsc-specifier:\fB
4335: auto
4336: static
4337: extern
4338: register
4339: typedef
4340: .DE
4341: .DS
4342: \fItype-specifier:
4343: struct-or-union-specifier
4344: typedef-name
4345: enum-specifier
4346: basic-type-specifier:
4347: basic-type
4348: basic-type basic-type-specifiers
4349: basic-type:\fB
4350: char
4351: short
4352: int
4353: long
4354: unsigned
4355: float
4356: double
4357: void\fR
4358: .DE
4359: .DS
4360: \fIenum-specifier:\fB
4361: enum\fI { enum-list }\fB
4362: enum \fIidentifier { enum-list }\fB
4363: enum \fIidentifier
4364: .DE
4365: .DS
4366: \fIenum-list:
4367: enumerator
4368: enum-list , enumerator
4369: .DE
4370: .DS
4371: \fIenumerator:
4372: identifier
4373: identifier = constant-expression
4374: .DE
4375: .DS
4376: \fIinit-declarator-list:
4377: init-declarator
4378: init-declarator , init-declarator-list
4379: .DE
4380: .DS
4381: \fIinit-declarator:
4382: declarator initializer\v'0.5'\s-2opt\s0\v'-0.5'
4383: .DE
4384: .DS
4385: \fIdeclarator:
4386: identifier
4387: ( declarator )
4388: \(** declarator
4389: declarator ()
4390: declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]
4391: .DE
4392: .DS
4393: \fIstruct-or-union-specifier:\fB
4394: struct\fI { struct-decl-list }\fB
4395: struct \fIidentifier { struct-decl-list }\fB
4396: struct \fIidentifier\fB
4397: union { \fIstruct-decl-list }\fB
4398: union \fIidentifier { struct-decl-list }\fB
4399: union \fIidentifier
4400: .DE
4401: .DS
4402: \fIstruct-decl-list:
4403: struct-declaration
4404: struct-declaration struct-decl-list
4405: .DE
4406: .DS
4407: \fIstruct-declaration:
4408: type-specifier struct-declarator-list ;
4409: .DE
4410: .DS
4411: \fIstruct-declarator-list:
4412: struct-declarator
4413: struct-declarator , struct-declarator-list
4414: .DE
4415: .DS
4416: \fIstruct-declarator:
4417: declarator
4418: declarator : constant-expression
4419: : constant-expression
4420: .DE
4421: .DS
4422: \fIinitializer:
4423: = expression
4424: = { initializer-list }
4425: = { initializer-list , }
4426: .DE
4427: .DS
4428: \fIinitializer-list:
4429: expression
4430: initializer-list , initializer-list
4431: { initializer-list }
4432: { initializer-list , }
4433: .DE
4434: .DS
4435: \fItype-name:
4436: type-specifier abstract-declarator
4437: .DE
4438: .DS
4439: \fIabstract-declarator:
4440: empty
4441: ( abstract-declarator )
4442: \(** abstract-declarator
4443: abstract-declarator ()
4444: abstract-declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]
4445: .DE
4446: .DS
4447: \fItypedef-name:
4448: identifier
4449: .nr Hu 1
4450: .DE
4451: .NH 2
4452: Statements
4453: .PP
4454: .DS
4455: \fIcompound-statement:
4456: { declaration-list\v'0.5'\s-2opt\s0\v'-0.5' statement-list\v'0.5'\s-2opt\s0\v'-0.5' }
4457: .DE
4458: .DS
4459: \fIdeclaration-list:
4460: declaration
4461: declaration declaration-list
4462: .DE
4463: .DS
4464: \fIstatement-list:
4465: statement
4466: statement statement-list
4467: .DE
4468: .DS
4469: \fIstatement:
4470: compound-statement
4471: expression ;
4472: \fBif\fI ( expression ) statement
4473: \fBif\fI ( expression ) statement \fBelse\fI statement
4474: \fBwhile\fI ( expression ) statement
4475: \fBdo\fI statement \fBwhile\fI ( expression ) ;
4476: \fBfor\fI (exp\v'0.3'\s-2opt\s0\v'-0.3'\fB;\fIexp\v'0.3'\s-2opt\s0\v'-0.3'\fB;\fIexp\v'0.3'\s-2opt\s0\v'-0.3'\fI) statement
4477: \fBswitch\fI ( expression ) statement
4478: \fBcase\fI constant-expression : statement
4479: \fBdefault\fI : statement
4480: \fBbreak ;
4481: continue ;
4482: return ;
4483: return\fI expression ;
4484: \fBgoto\fI identifier ;
4485: identifier : statement
4486: ;\fR
4487: .nr Hu 1
4488: .DE
4489: .NH 2
4490: External definitions
4491: .PP
4492: .DS
4493: \fIprogram:
4494: external-definition
4495: external-definition program
4496: .DE
4497: .DS
4498: \fIexternal-definition:
4499: function-definition
4500: data-definition
4501: .DE
4502: .DS
4503: \fIfunction-definition:
4504: decl-specifier\v'0.5'\s-2opt\s0\v'-0.5' function-declarator function-body
4505: .DE
4506: .DS
4507: \fIfunction-declarator:
4508: declarator ( parameter-list\v'0.5'\s-2opt\s0\v'-0.5' )
4509: .DE
4510: .DS
4511: \fIparameter-list:
4512: identifier
4513: identifier , parameter-list
4514: .DE
4515: .DS
4516: \fIfunction-body:
4517: declaration-list\v'0.5'\s-2opt\s0\v'-0.5' compound-statement
4518: .DE
4519: .DS
4520: \fIdata-definition:
4521: \fBextern\fI declaration\fB ;
4522: \fBstatic\fI declaration\fB ;
4523: .DE
4524: .NH
4525: Preprocessor
4526: .DS
4527: \fB#define\fI identifier token-string\v'0.3'\s-2opt\s0\v'-0.3'\fB
4528: \fB#define\fI identifier\fB(\fIidentifier\fB,...)\fItoken-string\v'0.5'\s-2opt\s0\v'-0.5'\fB
4529: \fB#undef\fI identifier\fB
4530: \fB#include "\fIfilename\|\fB"
4531: #include <\fIfilename\|\fB>
4532: \fB#if\fI restricted-constant-expression\fB
4533: \fB#ifdef\fI identifier\fB
4534: \fB#ifndef\fI identifier\fB
4535: \fB#else
4536: \fB#endif
4537: \fB#line\fI constant \fB"\fIfilename\|\fB"
4538: .sp 5
4539: .DE
4540: .TC 2 1 3 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.