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