turns printfs back on
[freebsd-src/fkvm-freebsd.git] / share / doc / psd / 06.Clang / Clang.ms
blob639591349e82c6ef331a6289767f5c6b9da8a62d
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 .\"
39 .\" $FreeBSD$
40 .nr Cl 2
41 .TL
42 The C Programming Language - Reference Manual
43 .AU
44 Dennis M. Ritchie
45 .AI
46 AT&T Bell Laboratories
47 Murray Hill, NJ 07974
48 .PP
49 This manual is a reprint, with updates to the current C standard, from
50 \fIThe C Programming Language\fR,
51 by Brian W. Kernighan and Dennis M. Ritchie, Prentice-Hall, Inc., 1978.
52 .PP
53 \fBThis document is of historical interest only.  Do not use it as a reference
54 for modern implementations of C.\fP
55 .EH 'PSD:6-%''The C Programming Language - Reference Manual'
56 .OH 'The C Programming Language - Reference Manual''PSD:6-%'
57 .NH 1
58 Introduction
59 .PP
60 This manual describes the C language on the DEC PDP-11\(dg, the DEC VAX-11,
61 .FS
62 .LP
63 \(dg DEC PDP-11, and DEC VAX-11 are trademarks of Digital Equipment Corporation.
64 .LP
65 \(dd 3B 20 is a trademark of AT&T.
66 .FE
67 and the AT&T 3B 20\(dd.
68 Where differences exist, it concentrates on the VAX, but tries to point
69 out implementation-dependent details.  With few exceptions, these dependencies
70 follow directly from the underlying properties of the hardware; the various
71 compilers are generally quite compatible.
72 .NH 1
73 Lexical Conventions
74 .PP
75 There are six classes of tokens\ -\
76 identifiers, keywords, constants, strings, operators, and other separators.
77 Blanks, tabs, new\(hylines,
78 and comments (collectively, ``white space'') as described below
79 are ignored except as they serve to separate
80 tokens.
81 Some white space is required to separate
82 otherwise adjacent identifiers,
83 keywords, and constants.
84 .PP
85 If the input stream has been parsed into tokens
86 up to a given character, the next token is taken
87 to include the longest string of characters
88 which could possibly constitute a token.
89 .NH 2
90 Comments
91 .PP
92 The characters
96 introduce a comment which terminates
97 with the characters
98 \fB\(**/\fR.
99 Comments do not nest.
100 .NH 2
101 Identifiers (Names)
103 An identifier is a sequence of letters and digits.
104 The first character must be a letter.
105 The underscore
106 (\fB_\fR)
107 counts as a letter.
108 Uppercase and lowercase letters
109 are different.
110 Although there is no limit on the length of a name,
111 only initial characters are significant: at least
112 eight characters of a non-external name, and perhaps
113 fewer for external names.
114 Moreover, some implementations may collapse case
115 distinctions for external names.
116 The external name sizes include:
119 l l.
120 PDP-11  7 characters, 2 cases
121 VAX-11  >100 characters, 2 cases
122 AT&T 3B 20      >100 characters, 2 cases
126 .NH 2
127 Keywords
129 The following identifiers are reserved for use
130 as keywords and may not be used otherwise:
132 .ta 0.8i 1.6i 2.4i 3.2i 4.0i
133 \fBauto do      for     return  typedef
134 break   double  goto    short   union
135 case    else    if      sizeof  unsigned
136 char    enum    int     static  void
137 continue        external        long    struct  while
138 default float   register        switch\fR
139 .ta 0.5i
142 Some implementations also reserve the words
144 fortran, asm, gfloat, hfloat
147 .B quad
149 .NH 2
150 Constants
152 There are several kinds
153 of constants.
154 Each has a type; an introduction to types is given in ``NAMES.''
155 Hardware characteristics that affect sizes are summarized in
156 ``Hardware Characteristics'' under ``LEXICAL CONVENTIONS.''
157 .NH 3
158 Integer Constants
161 An integer constant consisting of a sequence of digits
162 is taken
163 to be octal if it begins with
167 (digit zero).
168 An octal constant consists of the digits \fB0\fR through \fB7\fR only.
169 A sequence of digits preceded by
177 (digit zero) is taken to be a hexadecimal integer.
178 The hexadecimal digits include
186 through
194 with values 10 through 15.
195 Otherwise, the integer constant is taken to be decimal.
196 A decimal constant whose value exceeds the largest
197 signed machine integer is taken to be
198 \fBlong\fR;
199 an octal or hex constant which exceeds the largest unsigned machine integer
200 is likewise taken to be
202 long\fR.
204 Otherwise, integer constants are \fBint\fR.
205 .NH 3
206 Explicit Long Constants
209 A decimal, octal, or hexadecimal integer constant immediately followed
214 (letter ell)
219 is a long constant.
220 As discussed below,
221 on some machines
222 integer and long values may be considered identical.
223 .NH 3
224 Character Constants
227 A character constant is a character enclosed in single quotes,
228 as in '\fBx\fR'.
229 The value of a character constant is the numerical value of the
230 character in the machine's character set.
232 Certain nongraphic characters,
233 the single quote
234 (\fB'\fR)
235 and the backslash
236 (\fB\e\fR),
237 may be represented according to the following table
238 of escape sequences:
241 l l l.
242 new\(hyline     NL (LF) \en
243 horizontal tab  HT      \et
244 vertical tab    VT      \ev
245 backspace       BS      \eb
246 carriage return CR      \er
247 form feed       FF      \ef
248 backslash       \e      \e\e
249 single quote    '       \e'
250 bit pattern     \fIddd\fR\^     \e\fIddd\fR\^
254 The escape
255 \e\fIddd\fR
256 consists of the backslash followed by 1, 2, or 3 octal digits
257 which are taken to specify the value of the
258 desired character.
259 A special case of this construction is
263 (not followed
264 by a digit), which indicates the character
266 NUL\fR.
268 If the character following a backslash is not one
269 of those specified, the
270 behavior is undefined.
271 A new-line character is illegal in a character constant.
272 The type of a character constant is \fBint\fR.
273 .NH 3
274 Floating Constants
277 A floating constant consists of
278 an integer part, a decimal point, a fraction part,
284 \fBE\fR,
285 and an optionally signed integer exponent.
286 The integer and fraction parts both consist of a sequence
287 of digits.
288 Either the integer part or the fraction
289 part (not both) may be missing.
290 Either the decimal point or
295 and the exponent (not both) may be missing.
296 Every floating constant has type \fBdouble\fR.
297 .NH 3
298 Enumeration Constants
301 Names declared as enumerators
302 (see ``Structure, Union, and Enumeration Declarations'' under
303 ``DECLARATIONS'')
304 have type \fBint\fR.
305 .NH 2
306 Strings
308 A string is a sequence of characters surrounded by
309 double quotes,
310 as in
311 \fB"..."\fR.
312 A string has type
313 ``array of \fBchar\fR'' and storage class
314 \fBstatic\fR
315 (see ``NAMES'')
316 and is initialized with
317 the given characters.
318 The compiler places
319 a null byte
320 (\fB\e0\fR)
321 at the end of each string so that programs
322 which scan the string can
323 find its end.
324 In a string, the double quote character
325 (\fB"\fR)
326 must be preceded by
328 \fB\e\fR;
329 in addition, the same escapes as described for character
330 constants may be used.
337 the immediately following new\(hyline are ignored.
338 All strings, even when written identically, are distinct.
339 .NH 2
340 Hardware Characteristics
342 The following figure summarize
343 certain hardware properties that vary from machine to machine.
346 center box;
347 c cfB s cfB s cfB s
348 c c s c s c s
349 l | l1 lp8 | l1 lp8 | l1 lp8.
350         DEC PDP\-11     DEC VAX-11      AT&T 3B
351         (ASCII) (ASCII) (ASCII)
354 char    8 bits          8 bits          8bits
355 int     16              32              32
356 short   16              16              16
357 long    32              32              32
358 float   32              32              32
359 double  64              64              64
360 float range        \(+-10       \(+-38     \(+-10       \(+-38      \(+-10      \(+-38
361 \^      \^              \^              \^
362 double range       \(+-10       \(+-38     \(+-10       \(+-38      \(+-10      \(+-308
363 \^      \^              \^              \^
365 .\" .FG 4 4 1 "DEC PDP-11 HARDWARE CHARACTERISTICS"
368 .NH 1
369 Syntax Notation
371 Syntactic categories are indicated by
373 italic
375 type
376 and literal words and characters
378 \fBbold\fR
379 type.
380 Alternative categories are listed on separate lines.
381 An optional terminal or nonterminal symbol is
382 indicated by the subscript ``opt,'' so that
384 { \fIexpression\v'0.5'\s-2opt\s0\v'-0.5'\fR }
387 indicates an optional expression enclosed in braces.
388 The syntax is summarized in ``SYNTAX SUMMARY''.
389 .NH 1
390 Names
392 The C language bases the interpretation of an
393 identifier upon two attributes of the identifier \(mi its
395 storage class
397 and its
399 type\fR.
400 The storage class determines the location and lifetime
401 of the storage associated with an identifier;
402 the type determines
403 the meaning of the values
404 found in the identifier's storage.
405 .NH 2
406 Storage Class
408 .\" The original text had borrowed BL, LI and LE from the mm macros.
409 .\" That way madness lies.
410 There are four declarable storage classes:
413 \(bu Automatic
415 \(bu Static
417 \(bu External
419 \(bu Register.
422 Automatic variables are local to each invocation of
423 a block (see ``Compound Statement or Block'' in
424 ``STATEMENTS'') and are discarded upon exit from the block.
425 Static variables are local to a block but retain
426 their values upon reentry to a block even after control
427 has left the block.
428 External variables exist and retain their values throughout
429 the execution of the entire program and
430 may be used for communication between
431 functions, even separately compiled functions.
432 Register variables are (if possible) stored in the fast registers
433 of the machine; like automatic
434 variables, they are local to each block and disappear on exit from the block.
435 .NH 2
436 Type
438 The C language supports several
439 fundamental
440 types of objects.
441 Objects declared as characters
442 (\fBchar\fR)
443 are large enough to store any member of the implementation's
444 character set.
445 If a genuine character from that character set is
446 stored in a \fBchar\fR variable,
447 its value is equivalent to the integer code for that character.
448 Other quantities may be stored into character variables, but
449 the implementation is machine dependent.
450 In particular, \fBchar\fR may be signed or unsigned by default.
452 Up to three sizes of integer, declared
454 short
456 \fBint\fR,
457 \fBint\fR,
460 long
462 \fBint\fR,
463 are available.
464 Longer integers provide no less storage than shorter ones,
465 but the implementation may make either short integers or long integers,
466 or both, equivalent to plain integers.
467 ``Plain'' integers have the natural size suggested
468 by the host machine architecture.
469 The other sizes are provided to meet special needs.
471 The properties of \fBenum\fR types (see ``Structure, Union, and Enumeration Declarations''
472 under ``DECLARATIONS'')
473 are identical to those of
474 some integer types.
475 The implementation may use the range of values to
476 determine how to allocate storage.
478 Unsigned
479 integers, declared
481 unsigned,
483 obey the laws of arithmetic modulo
484 2\v'-0.5'\fIn\fR\v'0.5'
485 where \fIn\fR is the number of bits in the representation.
486 (On the
487 PDP-11,
488 unsigned long quantities are not supported.)
490 Single-precision floating point
491 (\fBfloat\fR)
492 and double precision floating point
493 (\fBdouble\fR)
494 may be synonymous in some implementations.
496 Because objects of the foregoing types can usefully be interpreted
497 as numbers, they will be referred to as
499 arithmetic
501 types.
502 \fBChar\fR,
506 of all sizes whether \fBunsigned\fR or not, and
508 enum
510 will collectively be called
512 integral
514 types.
517 float
521 double
523 types will collectively be called
525 floating
527 types.
531 void
533 type
534 specifies an empty set of values.
535 It is used as the type returned by functions that
536 generate no value.
538 Besides the fundamental arithmetic types, there is a
539 conceptually infinite class of derived types constructed
540 from the fundamental types in the following ways:
541 .IP \fIArrays\fR
542 of objects of most types
543 .IP \fIFunctions\fR
544 which return objects of a given type
545 .IP \fIPointers\fR
546 to objects of a given type
547 .IP \fIStructures\fR
548 containing a sequence of objects of various types
549 .IP \fIUnions\fR
550 capable of containing any one of several objects of various types.
552 In general these methods
553 of constructing objects can
554 be applied recursively.
555 .NH 1
556 Objects and Lvalues
560 object
562 is a manipulatable region of storage.
565 lvalue
567 is an expression referring to an object.
568 An obvious example of an lvalue
569 expression is an identifier.
570 There are operators which yield lvalues:
571 for example,
576 is an expression of pointer type, then
578 \(**E
580 is an lvalue
581 expression referring to the object to which
585 points.
586 The name ``lvalue'' comes from the assignment expression
588 E1\ =\ E2
590 in which the left operand
594 must be
595 an lvalue expression.
596 The discussion of each operator
597 below indicates whether it expects lvalue operands and whether it
598 yields an lvalue.
599 .NH 1
600 Conversions
602 A number of operators may, depending on their operands,
603 cause conversion of the value of an operand from one type to another.
604 This part explains the result to be expected from such
605 conversions.
606 The conversions demanded by most ordinary operators are summarized under
607 ``Arithmetic Conversions.''
608 The summary will be supplemented
609 as required by the discussion
610 of each operator.
611 .NH 2
612 Characters and Integers
614 A character or a short integer may be used wherever an
615 integer may be used.
616 In all cases
617 the value is converted to an integer.
618 Conversion of a shorter integer
619 to a longer preserves sign.
620 Whether or not sign-extension occurs for characters is machine
621 dependent, but it is guaranteed that a member of the
622 standard character set is non-negative.
623 Of the machines treated here,
624 only the
625 PDP-11
627 VAX-11
628 sign-extend.
629 On these machines,
631 char
633 variables range in value from
634 \(mi128 to 127.
635 The more explicit type
637 unsigned
640 char
642 forces the values to range from 0 to 255.
644 On machines that treat characters as signed,
645 the characters of the
646 ASCII
647 set are all non-negative.
648 However, a character constant specified
649 with an octal escape suffers sign extension
650 and may appear negative;
651 for example,
652 \fB\'\e377\'\fR
653 \fRhas the value
655 \(mi1\fR.
657 When a longer integer is converted to a shorter
658 integer
659 or to a
661 char,
663 it is truncated on the left.
664 Excess bits are simply discarded.
665 .NH 2
666 Float and Double
668 All floating arithmetic in C is carried out in double precision.
669 Whenever a
671 float
673 appears in an expression it is lengthened to
675 double
677 by zero padding its fraction.
678 When a
680 double
682 must be
683 converted to
684 \fBfloat\fR,
685 for example by an assignment,
688 double
690 is rounded before
691 truncation to
693 float
695 length.
696 This result is undefined if it cannot be represented as a float.
697 On the VAX, the compiler can be directed to use single precision for expressions
698 containing only float and integer operands.
699 .NH 2
700 Floating and Integral
702 Conversions of floating values to integral type
703 are rather machine dependent.
704 In particular, the direction of truncation of negative numbers
705 varies.
706 The result is undefined if
707 it will not fit in the space provided.
709 Conversions of integral values to floating type
710 are well behaved.
711 Some loss of accuracy occurs
712 if the destination lacks sufficient bits.
713 .NH 2
714 Pointers and Integers
716 An expression of integral type may be added to or subtracted from
717 a pointer; in such a case,
718 the first is converted as
719 specified in the discussion of the addition operator.
720 Two pointers to objects of the same type may be subtracted;
721 in this case, the result is converted to an integer
722 as specified in the discussion of the subtraction
723 operator.
724 .NH 2
725 Unsigned
727 Whenever an unsigned integer and a plain integer
728 are combined, the plain integer is converted to unsigned
729 and the result is unsigned.
730 The value
731 is the least unsigned integer congruent to the signed
732 integer (modulo 2\v'-0.3'\s-2wordsize\s+2\v'0.3').
733 In a 2's complement representation,
734 this conversion is conceptual; and there is no actual change in the
735 bit pattern.
737 When an unsigned \fBshort\fR integer is converted to
738 \fBlong\fR,
739 the value of the result is the same numerically as that of the
740 unsigned integer.
741 Thus the conversion amounts to padding with zeros on the left.
742 .NH 2
743 Arithmetic Conversions
745 A great many operators cause conversions
746 and yield result types in a similar way.
747 This pattern will be called the ``usual arithmetic conversions.''
748 .IP 1.
749 First, any operands of type
751 char
755 short
757 are converted to
758 \fBint\fR,
759 and any operands of type \fBunsigned char\fR
760 or \fBunsigned short\fR are converted
761 to \fBunsigned int\fR.
762 .IP 2.
763 Then, if either operand is
765 double,
767 the other is converted to
769 double
771 and that is the type of the result.
772 .IP 3.
773 Otherwise, if either operand is \fBunsigned long\fR,
774 the other is converted to \fBunsigned long\fR and that
775 is the type of the result.
776 .IP 4.
777 Otherwise, if either operand is
778 \fBlong\fR,
779 the other is converted to
781 long
783 and that is the type of the result.
784 .IP 5.
785 Otherwise, if one operand is \fBlong\fR, and
786 the other is \fBunsigned int\fR, they are both
787 converted to \fBunsigned long\fR and that is
788 the type of the result.
789 .IP 6.
790 Otherwise, if either operand is
792 unsigned,
794 the other is converted to
796 unsigned
798 and that is the type of the result.
799 .IP 7.
800 Otherwise, both operands must be
801 \fBint\fR,
802 and that is the type of the result.
804 .NH 2
805 Void
807 The (nonexistent) value of a
809 void
811 object may not be used in any way,
812 and neither explicit nor implicit conversion may be applied.
813 Because a void expression denotes a nonexistent value,
814 such an expression may be used only
815 as an expression statement
816 (see ``Expression Statement'' under ``STATEMENTS'')
817 or as the left operand
818 of a comma expression (see ``Comma Operator'' under ``EXPRESSIONS'').
820 An expression may be converted to
821 type
823 void
825 by use of a cast.
826 For example, this makes explicit the discarding of the value
827 of a function call used as an expression statement.
828 .NH 1
829 Expressions
831 The precedence of expression operators is the same
832 as the order of the major
833 subsections of this section, highest precedence first.
834 Thus, for example, the expressions referred to as the operands of
836 \(pl
838 (see ``Additive Operators'')
839 are those expressions defined under ``Primary Expressions'',
840 ``Unary Operators'', and ``Multiplicative Operators''.
841 Within each subpart, the operators have the same
842 precedence.
843 Left- or right-associativity is specified
844 in each subsection for the operators
845 discussed therein.
846 The precedence and associativity of all the expression
847 operators are summarized in the
848 grammar of ``SYNTAX SUMMARY''.
850 Otherwise, the order of evaluation of expressions
851 is undefined.  In particular, the compiler
852 considers itself free to
853 compute subexpressions in the order it believes
854 most efficient
855 even if the subexpressions
856 involve side effects.
857 The order in which subexpression evaluation takes place is unspecified.
858 Expressions involving a commutative and associative
859 operator
860 (\fB\(**,\fR
861 \fB\(pl\fR,
862 \fB&\fR,
863 \fB|\fR,
864 \fB^\fR)
865 may be rearranged arbitrarily even in the presence
866 of parentheses;
867 to force a particular order of evaluation,
868 an explicit temporary must be used.
870 The handling of overflow and divide check
871 in expression evaluation
872 is undefined.
873 Most existing implementations of C ignore integer overflows;
874 treatment of
875 division by 0 and all floating-point exceptions
876 varies between machines and is usually
877 adjustable by a library function.
878 .NH 2
879 Primary Expressions
881 Primary expressions
882 involving \fB\.\fR,
883 \fB\(mi>\fR,
884 subscripting, and function calls
885 group left to right.
887 \fIprimary-expression:
888         identifier
889         constant
890         string
891         ( expression )
892         primary-expression [ expression ]
893         primary-expression ( expression-list\v'0.5'\s-2opt\s0\v'-0.5' )
894         primary-expression . identifier
895         primary-expression \(mi> identifier\fR
898 \fIexpression-list:
899         expression
900         expression-list , expression\fR
903 An identifier is a primary expression provided it has been
904 suitably declared as discussed below.
905 Its type is specified by its declaration.
906 If the type of the identifier is ``array of .\|.\|.'',
907 then the value of the identifier expression
908 is a pointer
909 to the first object in the array; and the
910 type of the expression is
911 ``pointer to .\|.\|.''.
912 Moreover, an array identifier is not an lvalue
913 expression.
914 Likewise, an identifier which is declared
915 ``function returning .\|.\|.'',
916 when used except in the function-name position
917 of a call, is converted to ``pointer to function returning .\|.\|.''.
920 constant is a primary expression.
921 Its type may be
922 \fBint\fR,
923 \fBlong\fR,
926 double
928 depending on its form.
929 Character constants have type
933 and floating constants have type
935 double\fR.
938 A string is a primary expression.
939 Its type is originally ``array of
940 \fBchar\fR'',
941 but following
942 the same rule given above for identifiers,
943 this is modified to ``pointer to
944 \fBchar\fR'' and
946 result is a pointer to the first character
947 in the string.
948 (There is an exception in certain initializers;
949 see ``Initialization'' under ``DECLARATIONS.'')
951 A parenthesized expression is a primary expression
952 whose type and value are identical
953 to those of the unadorned expression.
954 The presence of parentheses does
955 not affect whether the expression is an
956 lvalue.
958 A primary expression followed by an expression in square
959 brackets is a primary expression.
960 The intuitive meaning is that of a subscript.
961 Usually, the primary expression has type ``pointer to .\|.\|.'',
962 the subscript expression is
963 \fBint\fR,
964 and the type of the result is ``\|.\|.\|.\|''.
965 The expression
967 E1[E2]
970 identical (by definition) to
972 \(**((E1)\(plE2))\fR.
973 All the clues
974 needed to understand
975 this notation are contained in this subpart together
976 with the discussions
977 in ``Unary Operators'' and ``Additive Operators'' on identifiers,
979 \(**
983 \(pl
985 respectively.
986 The implications are summarized under ``Arrays, Pointers, and Subscripting''
987 under ``TYPES REVISITED.''
989 A function call is a primary expression followed by parentheses
990 containing a possibly
991 empty, comma-separated list of expressions
992 which constitute the actual arguments to the
993 function.
994 The primary expression must be of type ``function returning .\|.\|.,''
995 and the result of the function call is of type ``\|.\|.\|.\|''.
996 As indicated
997 below, a hitherto unseen identifier followed
998 immediately by a left parenthesis
999 is contextually declared
1000 to represent a function returning
1001 an integer;
1002 thus in the most common case, integer-valued functions
1003 need not be declared.
1005 Any actual arguments of type
1007 float
1010 converted to
1012 double
1014 before the call.
1015 Any of type
1017 char
1021 short
1023 are converted to
1025 int\fR.
1027 Array names are converted to pointers.
1028 No other conversions are performed automatically;
1029 in particular, the compiler does not compare
1030 the types of actual arguments with those of formal
1031 arguments.
1032 If conversion is needed, use a cast;
1033 see ``Unary Operators'' and ``Type Names'' under
1034 ``DECLARATIONS.''
1036 In preparing for the call to a function,
1037 a copy is made of each actual parameter.
1038 Thus, all argument passing in C is strictly by value.
1039 A function may
1040 change the values of its formal parameters, but
1041 these changes cannot affect the values
1042 of the actual parameters.
1043 It is possible
1044 to pass a pointer on the understanding
1045 that the function may change the value
1046 of the object to which the pointer points.
1047 An array name is a pointer expression.
1048 The order of evaluation of arguments is undefined by the language;
1049 take note that the various compilers differ.
1050 Recursive calls to any
1051 function are permitted.
1053 A primary expression followed by a dot followed by an identifier
1054 is an expression.
1055 The first expression must be a structure or a union, and the identifier
1056 must name a member of the structure or union.
1057 The value is the named member of the structure or union, and it is
1058 an lvalue if the first expression is an lvalue.
1060 A primary expression followed by an arrow (built from
1062 \(mi
1069 followed by an identifier
1070 is an expression.
1071 The first expression must be a pointer to a structure or a union
1072 and the identifier must name a member of that structure or union.
1073 The result is an lvalue referring to the named member
1074 of the structure or union
1075 to which the pointer expression points.
1076 Thus the expression
1078 E1\(mi>MOS
1080 is the same as
1082 (\(**E1).MOS\fR.
1084 Structures and unions are discussed in
1085 ``Structure, Union, and Enumeration Declarations'' under
1086 ``DECLARATIONS.''
1087 .NH 2
1088 Unary Operators
1090 Expressions with unary operators
1091 group right to left.
1092 .tr ~~
1094 \fIunary-expression:
1095         \(** expression
1096         & lvalue
1097         \(mi expression
1098         ! expression
1099         \s+2~\s0 expression
1100         \(pl\(pl lvalue
1101         \(mi\(milvalue
1102         lvalue \(pl\(pl
1103         lvalue \(mi\(mi
1104         ( type-name ) expression\fR
1105         sizeof\fI expression\fR
1106         sizeof\fI ( type-name )\fR
1109 The unary
1111 \(**
1113 operator
1114 means
1116 indirection
1119 the expression must be a pointer, and the result
1120 is an lvalue referring to the object to
1121 which the expression points.
1122 If the type of the expression is ``pointer to .\|.\|.,''
1123 the type of the result is ``\|.\|.\|.\|''.
1125 The result of the unary
1129 operator is a pointer
1130 to the object referred to by the
1131 lvalue.
1132 If the type of the lvalue is ``\|.\|.\|.\|'',
1133 the type of the result is ``pointer to .\|.\|.''.
1135 The result
1136 of the unary
1138 \(mi
1140 operator
1141 is the negative of its operand.
1142 The usual arithmetic conversions are performed.
1143 The negative of an unsigned quantity is computed by
1144 subtracting its value from
1145 2\v'-0.5'\fIn\fR\^\v'0.5' where \fIn\fR\^ is the number of bits in
1146 the corresponding signed type.
1148 .tr ~~
1149 There is no unary
1151 \(pl
1153 operator.
1155 The result of the logical negation operator
1159 is one if the value of its operand is zero, zero if the value of its
1160 operand is nonzero.
1161 The type of the result is
1163 int\fR.
1165 It is applicable to any arithmetic type
1166 or to pointers.
1170 \s+2~\s0
1172 operator yields the one's complement of its operand.
1173 The usual arithmetic conversions are performed.
1174 The type of the operand must be integral.
1176 The object referred to by the lvalue operand of prefix
1178 \(pl\(pl
1180 is incremented.
1181 The value is the new value of the operand
1182 but is not an lvalue.
1183 The expression
1185 \(pl\(plx
1187 is equivalent to
1188 \fBx=x\(pl1\fR.
1189 See the discussions ``Additive Operators'' and ``Assignment
1190 Operators'' for information on conversions.
1192 The lvalue operand of prefix
1194 \(mi\(mi
1196 is decremented
1197 analogously to the
1198 prefix
1200 \(pl\(pl
1202 operator.
1204 When postfix
1206 \(pl\(pl
1208 is applied to an lvalue,
1209 the result is the value of the object referred to by the lvalue.
1210 After the result is noted, the object
1211 is incremented in the same
1212 manner as for the prefix
1214 \(pl\(pl
1216 operator.
1217 The type of the result is the same as the type of the lvalue expression.
1219 When postfix
1221 \(mi\(mi
1223 is applied to an lvalue,
1224 the result is the value of the object referred to by the lvalue.
1225 After the result is noted, the object
1226 is decremented in the manner as for the prefix
1228 \(mi\(mi
1230 operator.
1231 The type of the result is the same as the type of the lvalue
1232 expression.
1234 An expression preceded by the parenthesized name of a data type
1235 causes conversion of the value of the expression to the named type.
1236 This construction is called a
1238 cast\fR.
1240 Type names are described in ``Type Names'' under ``Declarations.''
1244 sizeof
1246 operator yields the size
1247 in bytes of its operand.
1250 byte
1252 is undefined by the language
1253 except in terms of the value of
1255 sizeof\fR.
1257 However, in all existing implementations,
1258 a byte is the space required to hold a
1259 \fBchar.\fR)
1260 When applied to an array, the result is the total
1261 number of bytes in the array.
1262 The size is determined from
1263 the declarations of
1264 the objects in the expression.
1265 This expression is semantically an
1267 unsigned
1269 constant and may
1270 be used anywhere a constant is required.
1271 Its major use is in communication with routines
1272 like storage allocators and I/O systems.
1276 sizeof
1278 operator
1279 may also be applied to a parenthesized type name.
1280 In that case it yields the size in bytes of an object
1281 of the indicated type.
1283 The construction
1284 \fBsizeof(\fItype\|\fR\^)\fR\^
1285 is taken to be a unit,
1286 so the expression
1287 \fBsizeof(\fItype\|\fB)-2\fR
1288 is the same as
1289 \fB(sizeof(\fItype\|\fB))-2\fR.
1290 .NH 2
1291 Multiplicative Operators
1293 The multiplicative operators
1294 \fB\(**\fR,
1295 \fB/\fR,
1300 group left to right.
1301 The usual arithmetic conversions are performed.
1303 \fImultiplicative expression:
1304         expression \(** expression
1305         expression / expression
1306         expression % expression\fR
1309 The binary
1311 \(**
1313 operator indicates multiplication.
1316 \(**
1318 operator is associative,
1319 and expressions with several multiplications at the same
1320 level may be rearranged by the compiler.
1321 The binary
1325 operator indicates division.
1327 The binary
1331 operator yields the remainder
1332 from the division of the first expression by the second.
1333 The operands must be integral.
1335 When positive integers are divided, truncation is toward 0;
1336 but the form of truncation is machine-dependent
1337 if either operand is negative.
1338 On all machines covered by this manual,
1339 the remainder has the same sign as the dividend.
1340 It is always true that
1342 (a/b)\(**b\ \(pl a%b
1344 is equal to
1352 is not 0).
1353 .NH 2
1354 Additive Operators
1356 The additive operators
1358 \(pl
1362 \(mi
1364 group left to right.
1365 The usual arithmetic conversions are performed.
1366 There are some additional type possibilities for each operator.
1368 \fIadditive-expression:
1369         expression \(pl expression
1370         expression \(mi expression\fR
1373 The result of the
1375 \(pl
1377 operator is the sum of the operands.
1378 A pointer to an object in an array and
1379 a value of any integral type
1380 may be added.
1381 The latter is in all cases converted to
1382 an address offset
1383 by multiplying it
1384 by the length of the object to which the
1385 pointer points.
1386 The result is a pointer
1387 of the same type as the original pointer
1388 which points to another object in the same array,
1389 appropriately offset from the original object.
1390 Thus if
1394 is a pointer
1395 to an object in an array, the expression
1397 P\(pl1
1399 is a pointer
1400 to the next object in the array.
1401 No further type combinations are allowed for pointers.
1405 \(pl
1407 operator is associative,
1408 and expressions with several additions at the same level may
1409 be rearranged by the compiler.
1411 The result of the
1413 \(mi
1415 operator is the difference of the operands.
1416 The usual arithmetic conversions are performed.
1417 Additionally,
1418 a value of any integral type
1419 may be subtracted from a pointer,
1420 and then the same conversions for addition apply.
1422 If two pointers to objects of the same type are subtracted,
1423 the result is converted
1424 (by division by the length of the object)
1425 to an
1429 representing the number of
1430 objects separating
1431 the pointed-to objects.
1432 This conversion will in general give unexpected
1433 results unless the pointers point
1434 to objects in the same array, since pointers, even
1435 to objects of the same type, do not necessarily differ
1436 by a multiple of the object length.
1437 .NH 2
1438 Shift Operators
1440 The shift operators
1448 group left to right.
1449 Both perform the usual arithmetic conversions on their operands,
1450 each of which must be integral.
1451 Then the right operand is converted to
1452 \fBint\fR;
1453 the type of the result is that of the left operand.
1454 The result is undefined if the right operand is negative
1455 or greater than or equal to the length of the object in bits.
1456 On the VAX a negative right operand is interpreted as reversing
1457 the direction of the shift.
1459 \fIshift-expression:
1460         expression << expression
1461         expression >> expression\fR
1464 The value of
1466 E1<<E2
1472 (interpreted as a bit
1473 pattern) left-shifted
1477 bits.
1478 Vacated bits are 0 filled.
1479 The value of
1481 E1>>E2
1487 right-shifted
1491 bit positions.
1492 The right shift is guaranteed to be logical
1493 (0 fill)
1499 \fBunsigned\fR;
1500 otherwise, it may be
1501 arithmetic.
1502 .NH 2
1503 Relational Operators
1505 The relational operators group left to right.
1507 \fIrelational-expression:
1508         expression < expression
1509         expression > expression
1510         expression <= expression
1511         expression >= expression\fR
1514 The operators
1518 (less than),
1522 (greater than), \fB<=\fR
1523 (less than
1524 or equal to), and
1528 (greater than or equal to)
1529 all yield 0 if the specified relation is false
1530 and 1 if it is true.
1531 The type of the result is
1533 int\fR.
1534 The usual arithmetic conversions are performed.
1535 Two pointers may be compared;
1536 the result depends on the relative locations in the address space
1537 of the pointed-to objects.
1538 Pointer comparison is portable only when the pointers point to objects
1539 in the same array.
1540 .NH 2
1541 Equality Operators
1544 \fIequality-expression:
1545         expression == expression
1546         expression != expression\fR
1553 (equal to) and the
1557 (not equal to) operators
1558 are exactly analogous to the relational
1559 operators except for their lower
1560 precedence.
1561 (Thus
1563 a<b\ ==\ c<d
1565 is 1 whenever
1573 have the same truth value).
1575 A pointer may be compared to an integer
1576 only if the
1577 integer is the constant 0.
1578 A pointer to which 0 has been assigned is guaranteed
1579 not to point to any object
1580 and will appear to be equal to 0.
1581 In conventional usage, such a pointer is considered to be null.
1582 .NH 2
1583 Bitwise \s-1AND\s0 Operator
1586 \fIand-expression:
1587         expression & expression\fR
1594 operator is associative,
1595 and expressions involving
1599 may be rearranged.
1600 The usual arithmetic conversions are performed.
1601 The result is the bitwise
1603 function of the operands.
1604 The operator applies only to integral
1605 operands.
1606 .NH 2
1607 Bitwise Exclusive \s-1OR\s0 Operator
1609 \fIexclusive-or-expression:
1610         expression ^ expression\fR
1617 operator is associative,
1618 and expressions involving
1622 may be rearranged.
1623 The usual arithmetic conversions are performed;
1624 the result is
1625 the bitwise exclusive
1627 function of
1628 the operands.
1629 The operator applies only to integral
1630 operands.
1631 .NH 2
1632 Bitwise Inclusive \s-1OR\s0 Operator
1634 \fIinclusive-or-expression:
1635         expression | expression\fR
1642 operator is associative,
1643 and expressions involving
1647 may be rearranged.
1648 The usual arithmetic conversions are performed;
1649 the result is the bitwise inclusive
1651 function of its operands.
1652 The operator applies only to integral
1653 operands.
1654 .NH 2
1655 Logical \s-1AND\s0 Operator
1657 \fIlogical-and-expression:
1658         expression && expression\fR
1665 operator groups left to right.
1666 It returns 1 if both its operands
1667 evaluate to nonzero, 0 otherwise.
1668 Unlike
1669 \fB&\fR,
1673 guarantees left to right
1674 evaluation; moreover, the second operand is not evaluated
1675 if the first operand is 0.
1677 The operands need not have the same type, but each
1678 must have one of the fundamental
1679 types or be a pointer.
1680 The result is always
1682 int\fR.
1684 .NH 2
1685 Logical \s-1OR\s0 Operator
1687 \fIlogical-or-expression:
1688         expression || expression\fR
1695 operator groups left to right.
1696 It returns 1 if either of its operands
1697 evaluates to nonzero, 0 otherwise.
1698 Unlike
1699 \fB|\fR,
1703 guarantees left to right evaluation; moreover,
1704 the second operand is not evaluated
1705 if the value of the first operand is nonzero.
1707 The operands need not have the same type, but each
1708 must
1709 have one of the fundamental types
1710 or be a pointer.
1711 The result is always
1713 int\fR.
1715 .NH 2
1716 Conditional Operator
1718 \fIconditional-expression:
1719         expression ? expression : expression\fR
1722 Conditional expressions group right to left.
1723 The first expression is evaluated;
1724 and if it is nonzero, the result is the value of the
1725 second expression, otherwise that of third expression.
1726 If possible, the usual arithmetic conversions are performed
1727 to bring the second and third expressions to a common type.
1728 If both are structures or unions of the same type,
1729 the result has the type of the structure or union.
1730 If both pointers are of the same type,
1731 the result has the common type.
1732 Otherwise, one must be a pointer and the other the constant 0,
1733 and the result has the type of the pointer.
1734 Only one of the second and third
1735 expressions is evaluated.
1736 .NH 2
1737 Assignment Operators
1739 There are a number of assignment operators,
1740 all of which group right to left.
1741 All require an lvalue as their left operand,
1742 and the type of an assignment expression is that
1743 of its left operand.
1744 The value is the value stored in the
1745 left operand after the assignment has taken place.
1746 The two parts of a compound assignment operator are separate
1747 tokens.
1749 \fIassignment-expression:
1750         lvalue = expression
1751         lvalue \(pl= expression
1752         lvalue \(mi= expression
1753         lvalue \(**= expression
1754         lvalue /= expression
1755         lvalue %= expression
1756         lvalue >>= expression
1757         lvalue <<= expression
1758         lvalue &= expression
1759         lvalue ^= expression
1760         lvalue |= expression\fR
1763 In the simple assignment with
1764 \fB=\fR,
1765 the value of the expression replaces that of the object
1766 referred
1767 to by the lvalue.
1768 If both operands have arithmetic type,
1769 the right operand is converted to the type of the left
1770 preparatory to the assignment.
1771 Second, both operands may be structures or unions of the same type.
1772 Finally, if the left operand is a pointer, the right operand must in general be a pointer
1773 of the same type.
1774 However, the constant 0 may be assigned to a pointer;
1775 it is guaranteed that this value will produce a null
1776 pointer distinguishable from a pointer to any object.
1778 The behavior of an expression
1779 of the form
1780 \fBE1\fR\^ \fIop\fR\^ = \fBE2\fR\^
1781 may be inferred by
1782 taking it as equivalent to
1783 \fBE1 = E1 \fIop\fR\^ (\fBE2\fR\^);
1784 however,
1788 is evaluated only once.
1791 \(pl=
1794 \fB\(mi=\fR,
1795 the left operand may be a pointer; in which case, the (integral) right
1796 operand is converted as explained
1797 in ``Additive Operators.''
1798 All right operands and all nonpointer left operands must
1799 have arithmetic type.
1800 .NH 2
1801 Comma Operator
1803 \fIcomma-expression:
1804         expression , expression\fR
1807 A pair of expressions separated by a comma is evaluated
1808 left to right, and the value of the left expression is
1809 discarded.
1810 The type and value of the result are the
1811 type and value of the right operand.
1812 This operator groups left to right.
1813 In contexts where comma is given a special meaning,
1814 e.g., in lists of actual arguments
1815 to functions (see ``Primary Expressions'') and lists
1816 of initializers (see ``Initialization'' under ``DECLARATIONS''),
1817 the comma operator as described in this subpart
1818 can only appear in parentheses. For example,
1820 \fBf(a, (t=3, t\(pl2), c)\fR
1823 has three arguments, the second of which has the value 5.
1824 .NH 1
1825 Declarations
1827 Declarations are used to specify the interpretation
1828 which C gives to each identifier; they do not necessarily
1829 reserve storage associated with the identifier.
1830 Declarations have the form
1832 \fIdeclaration:
1833         decl-specifiers declarator-list\v'0.5'\s-2opt\s0\v'-0.5' ;\fR
1836 The declarators in the declarator-list
1837 contain the identifiers being declared.
1838 The decl-specifiers
1839 consist of a sequence of type and storage class specifiers.
1841 \fIdecl-specifiers:
1842         type-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
1843         sc-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'\fR
1846 The list must be self-consistent in a way described below.
1847 .NH 2
1848 Storage Class Specifiers
1850 The sc-specifiers are:
1852 \fIsc-specifier:\fB
1853         auto
1854         static
1855         extern
1856         register
1857         typedef\fR
1862 typedef
1864 specifier does not reserve storage
1865 and is called a ``storage class specifier'' only for syntactic convenience.
1866 See ``Typedef'' for more information.
1867 The meanings of the various storage classes were discussed in ``Names.''
1870 \fBauto\fR,
1871 \fBstatic\fR,
1874 register
1876 declarations also serve as definitions
1877 in that they cause an appropriate amount of storage to be reserved.
1878 In the
1880 extern
1882 case,
1883 there must be an external definition (see ``External Definitions'')
1884 for the given identifiers
1885 somewhere outside the function in which they are declared.
1889 register
1891 declaration is best thought of as an
1893 auto
1895 declaration, together with a hint to the compiler
1896 that the variables declared will be heavily used.
1897 Only the first few
1898 such declarations in each function are effective.
1899 Moreover, only variables of certain types will be stored in registers;
1900 on the
1901 PDP-11,
1902 they are
1906 or pointer.
1907 One other restriction applies to register variables:
1908 the address-of operator
1912 cannot be applied to them.
1913 Smaller, faster programs can be expected if register declarations
1914 are used appropriately,
1915 but future improvements in code generation
1916 may render them unnecessary.
1918 At most, one sc-specifier may be given in a declaration.
1919 If the sc-specifier is missing from a declaration, it
1920 is taken to be
1922 auto
1924 inside a function,
1926 extern
1928 outside.
1929 Exception:
1930 functions are never
1931 automatic.
1932 .NH 2
1933 Type Specifiers
1935 The type-specifiers are
1937 \fItype-specifier:
1938         struct-or-union-specifier
1939         typedef-name
1940         enum-specifier
1941 basic-type-specifier:
1942         basic-type
1943         basic-type basic-type-specifiers
1944 basic-type:\fB
1945         char
1946         short
1947         int
1948         long
1949         unsigned
1950         float
1951         double
1952         void\fR
1955 At most one of the words \fBlong\fR or \fBshort\fR
1956 may be specified in conjunction with \fBint\fR;
1957 the meaning is the same as if \fBint\fR were not mentioned.
1958 The word \fBlong\fR may be specified in conjunction with
1959 \fBfloat\fR;
1960 the meaning is the same as \fBdouble\fR.
1961 The word \fBunsigned\fR may be specified alone, or
1962 in conjunction with \fBint\fR or any of its short
1963 or long varieties, or with \fBchar\fR.
1965 Otherwise, at most on type-specifier may be
1966 given in a declaration.
1967 In particular, adjectival use of \fBlong\fR,
1968 \fBshort\fR, or \fBunsigned\fR is not permitted
1969 with \fBtypedef\fR names.
1970 If the type-specifier is missing from a declaration,
1971 it is taken to be \fBint\fR.
1973 Specifiers for structures, unions, and enumerations are discussed in
1974 ``Structure, Union, and Enumeration Declarations.''
1975 Declarations with
1977 typedef
1979 names are discussed in ``Typedef.''
1980 .NH 2
1981 Declarators
1983 The declarator-list appearing in a declaration
1984 is a comma-separated sequence of declarators,
1985 each of which may have an initializer.
1987 \fIdeclarator-list:
1988         init-declarator
1989         init-declarator , declarator-list
1992 \fIinit-declarator:
1993         declarator initializer\v'0.5'\s-2opt\s0\v'-0.5'\fR
1996 Initializers are discussed in ``Initialization''.
1997 The specifiers in the declaration
1998 indicate the type and storage class of the objects to which the
1999 declarators refer.
2000 Declarators have the syntax:
2002 \fIdeclarator:
2003         identifier
2004         ( declarator )
2005         \(** declarator
2006         declarator ()
2007         declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]\fR
2010 The grouping is
2011 the same as in expressions.
2012 .NH 2
2013 Meaning of Declarators
2015 Each declarator is taken to be
2016 an assertion that when a construction of
2017 the same form as the declarator appears in an expression,
2018 it yields an object of the indicated
2019 type and storage class.
2021 Each declarator contains exactly one identifier; it is this identifier that
2022 is declared.
2023 If an unadorned identifier appears
2024 as a declarator, then it has the type
2025 indicated by the specifier heading the declaration.
2027 A declarator in parentheses is identical to the unadorned declarator,
2028 but the binding of complex declarators may be altered by parentheses.
2029 See the examples below.
2031 Now imagine a declaration
2033 \fBT D1\fR
2036 where
2040 is a type-specifier (like
2041 \fBint\fR,
2042 etc.)
2047 is a declarator.
2048 Suppose this declaration makes the identifier have type
2049 ``\|.\|.\|.\|
2054 where the ``\|.\|.\|.\|'' is empty if
2058 is just a plain identifier
2059 (so that the type of
2064 \fB`int x''\fR
2065 is just
2066 \fBint\fR).
2067 Then if
2071 has the form
2073 \fB\(**D\fR
2076 the type of the contained identifier is
2077 ``\|.\|.\|.\| pointer to
2081 \&.''
2087 has the form
2089 \fBD\|(\|\|)\|\fR
2092 then the contained identifier has the type
2093 ``\|.\|.\|. function returning
2094 \fBT\fR.''
2100 has the form
2102 \fBD\|[\|\fIconstant-expression\fB\|]\fR
2107 \fBD\|[\|]\|\fR
2110 then the contained identifier has type
2111 ``\|.\|.\|.\| array of
2112 \fBT\fR.''
2113 In the first case, the constant
2114 expression
2115 is an expression
2116 whose value is determinable at compile time
2117 , whose type is
2119 int\fR,
2120 and whose value is positive.
2121 (Constant expressions are defined precisely in ``Constant Expressions.'')
2122 When several ``array of'' specifications are adjacent, a multidimensional
2123 array is created;
2124 the constant expressions which specify the bounds
2125 of the arrays may be missing only for the first member of the sequence.
2126 This elision is useful when the array is external
2127 and the actual definition, which allocates storage,
2128 is given elsewhere.
2129 The first constant expression may also be omitted
2130 when the declarator is followed by initialization.
2131 In this case the size is calculated from the number
2132 of initial elements supplied.
2134 An array may be constructed from one of the basic types, from a pointer,
2135 from a structure or union,
2136 or from another array (to generate a multidimensional array).
2138 Not all the possibilities
2139 allowed by the syntax above are actually
2140 permitted.
2141 The restrictions are as follows:
2142 functions may not return
2143 arrays or functions
2144 although they may return pointers;
2145 there are no arrays of functions although
2146 there may be arrays of pointers to functions.
2147 Likewise, a structure or union may not contain a function;
2148 but it may contain a pointer to a function.
2150 As an example, the declaration
2152 \fBint i, \(**ip, f(), \(**fip(), (\(**pfi)();\fR
2155 declares an integer
2156 \fBi\fR,
2157 a pointer
2161 to an integer,
2162 a function
2166 returning an integer,
2167 a function
2171 returning a pointer to an integer,
2172 and a pointer
2176 to a function which
2177 returns an integer.
2178 It is especially useful to compare the last two.
2179 The binding of
2181 \(**fip()
2185 \(**(fip())\fR.
2187 The declaration suggests,
2188 and the same construction in an expression
2189 requires, the calling of a function
2191 fip\fR.
2193 Using indirection through the (pointer) result
2194 to yield an integer.
2195 In the declarator
2196 \fB(\(**pfi)()\fR,
2197 the extra parentheses are necessary, as they are also
2198 in an expression, to indicate that indirection through
2199 a pointer to a function yields a function, which is then called;
2200 it returns an integer.
2202 As another example,
2204 \fBfloat fa[17], \(**afp[17];\fR
2207 declares an array of
2209 float
2211 numbers and an array of
2212 pointers to
2214 float
2216 numbers.
2217 Finally,
2219 \fBstatic int x3d[3][5][7];\fR
2222 declares a static 3-dimensional array of integers,
2223 with rank 3\(mu5\(mu7.
2224 In complete detail,
2228 is an array of three items;
2229 each item is an array of five arrays;
2230 each of the latter arrays is an array of seven
2231 integers.
2232 Any of the expressions
2233 \fBx3d\fR,
2234 \fBx3d[i]\fR,
2235 \fBx3d[i][j]\fR,
2237 x3d[i][j][k]
2239 may reasonably appear in an expression.
2240 The first three have type ``array''
2241 and the last has type
2243 int\fR.
2245 .NH 2
2246 Structure and Union Declarations
2248 A structure
2249 is an object consisting of a sequence of named members.
2250 Each member may have any type.
2251 A union is an object which may, at a given time, contain any one
2252 of several members.
2253 Structure and union specifiers have the same form.
2255 \fIstruct-or-union-specifier:
2256         struct-or-union { struct-decl-list }
2257         struct-or-union identifier { struct-decl-list }
2258         struct-or-union identifier
2261 \fIstruct-or-union:\fB
2262         struct
2263         union\fR
2267 struct-decl-list
2268 .ne 4
2269 is a sequence of declarations for the members of the structure or union:
2271 \fIstruct-decl-list:
2272         struct-declaration
2273         struct-declaration struct-decl-list
2276 \fIstruct-declaration:
2277         type-specifier struct-declarator-list ;
2280 \fIstruct-declarator-list:
2281         struct-declarator
2282         struct-declarator , struct-declarator-list\fR
2285 In the usual case, a struct-declarator is just a declarator
2286 for a member of a structure or union.
2287 A structure member may also consist of a specified number of bits.
2288 Such a member is also called a
2290 field ;
2292 its length,
2293 a non-negative constant expression,
2294 is set off from the field name by a colon.
2296 \fIstruct-declarator:
2297         declarator
2298         declarator : constant-expression
2299         : constant-expression\fR
2302 Within a structure, the objects declared
2303 have addresses which increase as the declarations
2304 are read left to right.
2305 Each nonfield member of a structure
2306 begins on an addressing boundary appropriate
2307 to its type;
2308 therefore, there may
2309 be unnamed holes in a structure.
2310 Field members are packed into machine integers;
2311 they do not straddle words.
2312 A field which does not fit into the space remaining in a word
2313 is put into the next word.
2314 No field may be wider than a word.
2316 Fields are assigned right to left
2317 on the
2318 PDP-11
2320 VAX-11,
2321 left to right on the 3B 20.
2323 A struct-declarator with no declarator, only a colon and a width,
2324 indicates an unnamed field useful for padding to conform
2325 to externally-imposed layouts.
2326 As a special case, a field with a width of 0
2327 specifies alignment of the next field at an implementation dependent boundary.
2329 The language does not restrict the types of things that
2330 are declared as fields,
2331 but implementations are not required to support any but
2332 integer fields.
2333 Moreover,
2334 even
2338 fields may be considered to be unsigned.
2339 On the
2340 PDP-11,
2341 fields are not signed and have only integer values;
2342 on the
2343 VAX-11,
2344 fields declared with
2348 are treated as containing a sign.
2349 For these reasons,
2350 it is strongly recommended that fields be declared as
2352 unsigned\fR.
2354 In all implementations,
2355 there are no arrays of fields,
2356 and the address-of operator
2360 may not be applied to them, so that there are no pointers to
2361 fields.
2363 A union may be thought of as a structure all of whose members
2364 begin at offset 0 and whose size is sufficient to contain
2365 any of its members.
2366 At most, one of the members can be stored in a union
2367 at any time.
2369 A structure or union specifier of the second form, that is, one of
2371         \fBstruct \fIidentifier { struct-decl-list \fR}
2372         \fBunion \fIidentifier { struct-decl-list \fR}
2375 declares the identifier to be the
2377 structure tag
2379 (or union tag)
2380 of the structure specified by the list.
2381 A subsequent declaration may then use
2382 the third form of specifier, one of
2384         \fBstruct \fIidentifier\fR
2385         \fBunion \fIidentifier\fR
2388 Structure tags allow definition of self-referential
2389 structures. Structure tags also
2390 permit the long part of the declaration to be
2391 given once and used several times.
2392 It is illegal to declare a structure or union
2393 which contains an instance of
2394 itself, but a structure or union may contain a pointer to an instance of itself.
2396 The third form of a structure or union specifier may be
2397 used prior to a declaration which gives the complete specification
2398 of the structure or union in situations in which the size
2399 of the structure or union is unnecessary.
2400 The size is unnecessary in two situations: when a
2401 pointer to a structure or union is being declared and
2402 when a \fBtypedef\fR name is declared to be a synonym
2403 for a structure or union.
2404 This, for example, allows the declaration of a pair
2405 of structures which contain pointers to each other.
2407 The names of members and tags do not conflict
2408 with each other or with ordinary variables.
2409 A particular name may not be used twice
2410 in the same structure,
2411 but the same name may be used in several different structures in the same scope.
2413 A simple but important example of a structure declaration is
2414 the following binary tree structure:
2416 \fBstruct tnode
2418         char tword[20];
2419         int count;
2420         struct tnode \(**left;
2421         struct tnode \(**right;
2422 };\fR
2425 which contains an array of 20 characters, an integer, and two pointers
2426 to similar structures.
2427 Once this declaration has been given, the
2428 declaration
2430 \fBstruct tnode s, \(**sp;\fR
2433 declares
2437 to be a structure of the given sort
2442 to be a pointer to a structure
2443 of the given sort.
2444 With these declarations, the expression
2446 \fBsp->count\fR
2449 refers to the
2451 count
2453 field of the structure to which
2457 points;
2459 \fBs.left\fR
2462 refers to the left subtree pointer
2463 of the structure
2464 \fBs\fR;
2467 \fBs.right->tword[0]\fR
2470 refers to the first character of the
2472 tword
2474 member of the right subtree of
2476 s\fR.
2479 .NH 2
2480 Enumeration Declarations
2482 Enumeration variables and constants have integral type.
2484 \fIenum-specifier:\fB
2485         enum\fI { enum-list \fR}\fB
2486         enum \fIidentifier { enum-list \fR}\fB
2487         enum \fIidentifier
2489 enum-list:
2490         enumerator
2491         enum-list , enumerator
2493 enumerator:
2494         identifier
2495         identifier = constant-expression\fR
2498 The identifiers in an enum-list are declared as constants
2499 and may appear wherever constants are required.
2500 If no enumerators with
2504 appear, then the values of the
2505 corresponding constants begin at 0 and increase by 1 as the declaration is
2506 read from left to right.
2507 An enumerator with
2511 gives the associated identifier the value
2512 indicated; subsequent identifiers continue the progression from the assigned value.
2514 The names of enumerators in the same scope must all be distinct
2515 from each other and from those of ordinary variables.
2517 The role of the identifier in the enum-specifier
2518 is entirely analogous to that of the structure tag
2519 in a struct-specifier; it names a particular enumeration.
2520 For example,
2521 .DS L
2522 \fBenum color { chartreuse, burgundy, claret=20, winedark };
2523 \&...
2524 enum color *cp, col;
2525 \&...
2526 col = claret;
2527 cp = &col;
2528 \&...
2529 if (*cp == burgundy) ...\fR
2532 makes
2534 color
2536 the enumeration-tag of a type describing various colors,
2537 and then declares
2541 as a pointer to an object of that type,
2546 as an object of that type.
2547 The possible values are drawn from the set {0,1,20,21}.
2548 .NH 2
2549 Initialization
2551 A declarator may specify an initial value for the
2552 identifier being declared.
2553 The initializer is preceded by
2558 consists of an expression or a list of values nested in braces.
2560 \fIinitializer:
2561         = expression
2562         = { initializer-list }
2563         = { initializer-list , }
2566 \fIinitializer-list:
2567         expression
2568         initializer-list , initializer-list\fR
2569         { \fIinitializer-list \fR}
2570         { \fIinitializer-list\fR , }
2573 All the expressions in an initializer
2574 for a static or external variable must be constant
2575 expressions, which are described in ``CONSTANT EXPRESSIONS'',
2576 or expressions which reduce to the address of a previously
2577 declared variable, possibly offset by a constant expression.
2578 Automatic or register variables may be initialized by arbitrary
2579 expressions involving constants and previously declared variables and functions.
2581 Static and external variables that are not initialized are
2582 guaranteed to start off as zero.
2583 Automatic and register variables that are not initialized
2584 are guaranteed to start off as garbage.
2586 When an initializer applies to a
2588 scalar
2590 (a pointer or an object of arithmetic type),
2591 it consists of a single expression, perhaps in braces.
2592 The initial value of the object is taken from
2593 the expression; the same conversions as for assignment are performed.
2595 When the declared variable is an
2597 aggregate
2599 (a structure or array),
2600 the initializer consists of a brace-enclosed, comma-separated list of
2601 initializers for the members of the aggregate
2602 written in increasing subscript or member order.
2603 If the aggregate contains subaggregates, this rule
2604 applies recursively to the members of the aggregate.
2605 If there are fewer initializers in the list than there are members of the aggregate,
2606 then the aggregate is padded with zeros.
2607 It is not permitted to initialize unions or automatic aggregates.
2609 Braces may in some cases be omitted.
2610 If the initializer begins with a left brace, then
2611 the succeeding comma-separated list of initializers initializes
2612 the members of the aggregate;
2613 it is erroneous for there to be more initializers than members.
2614 If, however, the initializer does not begin with a left brace,
2615 then only enough elements from the list are taken to account
2616 for the members of the aggregate; any remaining members
2617 are left to initialize the next member of the aggregate of which
2618 the current aggregate is a part.
2620 A final abbreviation allows a
2622 char
2624 array to be initialized by a string.
2625 In this case successive characters of the string
2626 initialize the members of the array.
2628 For example,
2630 \fBint x[] = { 1, 3, 5 };\fR
2633 declares and initializes
2637 as a one-dimensional array which has three members, since no size was specified
2638 and there are three initializers.
2640 \fBfloat y[4][3] =
2642         { 1, 3, 5 },
2643         { 2, 4, 6 },
2644         { 3, 5, 7 },
2645 };\fR
2648 is a completely-bracketed initialization:
2649 1, 3, and 5 initialize the first row of
2650 the array
2651 \fBy[0]\fR,
2652 namely
2653 \fBy[0][0]\fR,
2654 \fBy[0][1]\fR,
2657 y[0][2]\fR.
2659 Likewise, the next two lines initialize
2661 y[1]
2665 y[2]\fR.
2667 The initializer ends early and therefore
2669 y[3]
2671 is initialized with 0.
2672 Precisely, the same effect could have been achieved by
2674 \fBfloat y[4][3] =
2676         1, 3, 5, 2, 4, 6, 3, 5, 7
2677 };\fR
2680 The initializer for
2684 begins with a left brace but that for
2686 y[0]
2688 does not;
2689 therefore, three elements from the list are used.
2690 Likewise, the next three are taken successively for
2692 y[1]
2696 y[2]\fR.
2698 Also,
2700 \fBfloat y[4][3] =
2702         { 1 }, { 2 }, { 3 }, { 4 }
2703 };\fR
2706 initializes the first column of
2710 (regarded as a two-dimensional array)
2711 and leaves the rest 0.
2713 Finally,
2715 \fBchar msg[] = "Syntax error on line %s\en";\fR
2718 shows a character array whose members are initialized
2719 with a string.
2720 .NH 2
2721 Type Names
2723 In two contexts (to specify type conversions explicitly
2724 by means of a cast
2725 and as an argument of
2726 \fBsizeof\fR),
2727 it is desired to supply the name of a data type.
2728 This is accomplished using a ``type name'', which in essence
2729 is a declaration for an object of that type which omits the name of
2730 the object.
2732 \fItype-name:
2733         type-specifier abstract-declarator
2736 \fIabstract-declarator:
2737         empty
2738         ( abstract-declarator )
2739         \(** abstract-declarator
2740         abstract-declarator ()
2741         abstract-declarator\fR\^ [ \fIconstant-expression\v'0.5'\s-2opt\s0\v'-0.5' \fR\^]
2744 To avoid ambiguity,
2745 in the construction
2747         \fI( abstract-declarator \fR)
2751 abstract-declarator
2752 is required to be nonempty.
2753 Under this restriction,
2754 it is possible to identify uniquely the location in the abstract-declarator
2755 where the identifier would appear if the construction were a declarator
2756 in a declaration.
2757 The named type is then the same as the type of the
2758 hypothetical identifier.
2759 For example,
2761 \fBint
2762 int \(**
2763 int \(**[3]
2764 int (\(**)[3]
2765 int \(**()
2766 int (\(**)()
2767 int (\(**[3])()\fR
2770 name respectively the types ``integer,'' ``pointer to integer,''
2771 ``array of three pointers to integers,''
2772 ``pointer to an array of three integers,''
2773 ``function returning pointer to integer,''
2774 ``pointer to function returning an integer,''
2775 and ``array of three pointers to functions returning an integer.''
2776 .NH 2
2777 Typedef
2779 Declarations whose ``storage class'' is
2781 typedef
2783 do not define storage but instead
2784 define identifiers which can be used later
2785 as if they were type keywords naming fundamental
2786 or derived types.
2788 \fItypedef-name:\fR
2789         \fIidentifier\fR
2792 Within the scope of a declaration involving
2793 \fBtypedef\fR,
2794 each identifier appearing as part of
2795 any declarator therein becomes syntactically
2796 equivalent to the type keyword
2797 naming the type
2798 associated with the identifier
2799 in the way described in ``Meaning of Declarators.''
2800 For example,
2801 after
2803 \fBtypedef int MILES, \(**KLICKSP;
2804 typedef struct { double re, im; } complex;\fR
2807 the constructions
2809 \fBMILES distance;
2810 extern KLICKSP metricp;
2811 complex z, \(**zp;\fR
2814 are all legal declarations; the type of
2816 distance
2819 \fBint\fR,
2820 that of
2822 metricp
2824 is ``pointer to \fBint\fR, ''
2825 and that of
2829 is the specified structure.
2834 is a pointer to such a structure.
2838 typedef
2840 does not introduce brand-new types, only synonyms for
2841 types which could be specified in another way.
2842 Thus
2843 in the example above
2845 distance
2847 is considered to have exactly the same type as
2848 any other
2852 object.
2853 .NH 1
2854 Statements
2856 Except as indicated, statements are executed in sequence.
2857 .NH 2
2858 Expression Statement
2860 Most statements are expression statements, which have
2861 the form
2863 \fIexpression \fR;
2866 Usually expression statements are assignments or function
2867 calls.
2868 .NH 2
2869 Compound Statement or Block
2871 So that several statements can be used where one is expected,
2872 the compound statement (also, and equivalently, called ``block'') is provided:
2874 \fIcompound-statement:
2875         { declaration-list\v'0.5'\s-2opt\s0\v'-0.5' statement-list\v'0.5'\s-2opt\s0\v'-0.5' }
2878 \fIdeclaration-list:
2879         declaration
2880         declaration declaration-list
2883 \fIstatement-list:
2884         statement
2885         statement statement-list\fR
2888 If any of the identifiers
2889 in the declaration-list were previously declared,
2890 the outer declaration is pushed down for the duration of the block,
2891 after which it resumes its force.
2893 Any initializations of
2895 auto
2899 register
2901 variables are performed each time the block is entered at the top.
2902 It is currently possible
2903 (but a bad practice)
2904 to transfer into a block;
2905 in that case the initializations are not performed.
2906 Initializations of
2908 static
2910 variables are performed only once when the program
2911 begins execution.
2912 Inside a block,
2914 extern
2916 declarations do not reserve storage
2917 so initialization is not permitted.
2918 .NH 2
2919 Conditional Statement
2921 The two forms of the conditional statement are
2923 \fBif\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
2924 \fBif\fR\^ ( \fIexpression\fR\^ ) \fIstatement \fBelse \fIstatement\fR\^
2927 In both cases, the expression is evaluated;
2928 and if it is nonzero, the first substatement
2929 is executed.
2930 In the second case, the second substatement is executed
2931 if the expression is 0.
2932 The ``else'' ambiguity is resolved by connecting
2935 else
2937 with the last encountered
2938 \fBelse\fR-less
2940 if\fR.
2942 .NH 2
2943 While Statement
2947 while
2949 statement has the form
2951 \fBwhile\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
2954 The substatement is executed repeatedly
2955 so long as the value of the
2956 expression remains nonzero.
2957 The test takes place before each execution of the
2958 statement.
2959 .NH 2
2960 Do Statement
2966 statement has the form
2968 \fBdo \fIstatement  \fBwhile\fR\^ ( \fIexpression \fR\^) ;
2971 The substatement is executed repeatedly until
2972 the value of the expression becomes 0.
2973 The test takes place after each execution of the
2974 statement.
2975 .NH 2
2976 For Statement
2982 statement has the form:
2984 \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
2988 Except for the behavior of \fBcontinue\fR,
2989 this statement is equivalent to
2991 \fIexp-1 \fR;
2992 \fBwhile\fR\^ ( \fIexp-2\ ) \fR\^
2994         \fIstatement
2995         exp-3 ;\fR
2999 Thus the first expression specifies initialization
3000 for the loop; the second specifies
3001 a test, made before each iteration, such
3002 that the loop is exited when the expression becomes
3004 The third expression often specifies an incrementing
3005 that is performed after each iteration.
3007 Any or all of the expressions may be dropped.
3008 A missing
3010 exp-2
3012 makes the
3013 implied
3015 while
3017 clause equivalent to
3018 \fBwhile(1)\fR;
3019 other missing expressions are simply
3020 dropped from the expansion above.
3021 .NH 2
3022 Switch Statement
3026 switch
3028 statement causes control to be transferred
3029 to one of several statements depending on
3030 the value of an expression.
3031 It has the form
3033 \fBswitch\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
3036 The usual arithmetic conversion is performed on the
3037 expression, but the result must be
3039 int\fR.
3041 The statement is typically compound.
3042 Any statement within the statement
3043 may be labeled with one or more case prefixes
3044 as follows:
3046 \fBcase \fIconstant-expression \fR:
3049 where the constant
3050 expression
3051 must be
3053 int\fR.
3055 No two of the case constants in the same switch
3056 may have the same value.
3057 Constant expressions are precisely defined in ``CONSTANT EXPRESSIONS.''
3059 There may also be at most one statement prefix of the
3060 form
3062 \fBdefault :\fR
3065 When the
3067 switch
3069 statement is executed, its expression
3070 is evaluated and compared with each case constant.
3071 If one of the case constants is
3072 equal to the value of the expression,
3073 control is passed to the statement
3074 following the matched case prefix.
3075 If no case constant matches the expression
3076 and if there is a
3077 \fBdefault\fR,
3078 prefix, control
3079 passes to the prefixed
3080 statement.
3081 If no case matches and if there is no
3082 \fBdefault\fR,
3083 then
3084 none of the statements in the
3085 switch is executed.
3087 The prefixes
3089 case
3093 default
3095 do not alter the flow of control,
3096 which continues unimpeded across such prefixes.
3097 To exit from a switch, see
3098 ``Break Statement.''
3100 Usually, the statement that is the subject of a switch is compound.
3101 Declarations may appear at the head of this
3102 statement,
3104 initializations of automatic or register variables
3105 are ineffective.
3106 .NH 2
3107 Break Statement
3109 The statement
3111 \fBbreak ;\fR
3114 causes termination of the smallest enclosing
3115 \fBwhile\fR,
3116 \fBdo\fR,
3117 \fBfor\fR,
3119 \fBswitch\fR
3120 statement;
3121 control passes to the
3122 statement following the terminated statement.
3123 .NH 2
3124 Continue Statement
3126 The statement
3128 \fBcontinue ;\fR
3131 causes control to pass to the loop-continuation portion of the
3132 smallest enclosing
3133 \fBwhile\fR,
3134 \fBdo\fR,
3136 \fBfor\fR
3137 statement; that is to the end of the loop.
3138 More precisely, in each of the statements
3141 lw(2i) lw(2i) lw(2i).
3142 \fBwhile (\|.\|.\|.\|) {        do {    for (\|.\|.\|.\|) {\fR
3143      \fIstatement ;          statement ;             statement ;\fR
3144      \fBcontin: ;            contin: ;       contin: ;
3145 }       } while (...);  }\fR
3151 continue
3153 is equivalent to
3155 goto\ contin\fR.
3157 (Following the
3159 contin:
3161 is a null statement, see ``Null Statement''.)
3162 .NH 2
3163 Return Statement
3165 A function returns to its caller by means of
3168 return
3170 statement which has one of the
3171 forms
3173 \fBreturn ;
3174 return \fIexpression \fR;
3177 In the first case, the returned value is undefined.
3178 In the second case, the value of the expression
3179 is returned to the caller
3180 of the function.
3181 If required, the expression is converted,
3182 as if by assignment, to the type of
3183 function in which it appears.
3184 Flowing off the end of a function is
3185 equivalent to a return with no returned value.
3186 The expression may be parenthesized.
3187 .NH 2
3188 Goto Statement
3190 Control may be transferred unconditionally by means of
3191 the statement
3193 \fBgoto \fIidentifier \fR;
3196 The identifier must be a label
3197 (see ``Labeled Statement'')
3198 located in the current function.
3199 .NH 2
3200 Labeled Statement
3202 Any statement may be preceded by
3203 label prefixes of the form
3205 \fIidentifier \fR:
3208 which serve to declare the identifier
3209 as a label.
3210 The only use of a label is as a target of a
3212 goto\fR.
3214 The scope of a label is the current function,
3215 excluding any subblocks in which the same identifier has been redeclared.
3216 See ``SCOPE RULES.''
3217 .NH 2
3218 Null Statement
3220 The null statement has the form
3222         \fB;\fR
3225 A null statement is useful to carry a label just before the
3229 of a compound statement or to supply a null
3230 body to a looping statement such as
3232 while\fR.
3234 .NH 1
3235 External Definitions
3237 A C program consists of a sequence of external definitions.
3238 An external definition declares an identifier to
3239 have storage class
3241 extern
3243 (by default)
3244 or perhaps
3245 \fBstatic\fR,
3247 a specified type.
3248 The type-specifier (see ``Type Specifiers'' in
3249 ``DECLARATIONS'') may also be empty, in which
3250 case the type is taken to be
3252 int\fR.
3254 The scope of external definitions persists to the end
3255 of the file in which they are declared just as the effect
3256 of declarations persists to the end of a block.
3257 The syntax of external definitions is the same
3258 as that of all declarations except that
3259 only at this level may the code for functions be given.
3260 .NH 2
3261 External Function Definitions
3263 Function definitions have the form
3265 \fIfunction-definition:
3266         decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5' function-declarator function-body\fR
3269 The only sc-specifiers
3270 allowed
3271 among the decl-specifiers
3274 extern
3277 \fBstatic\fR;
3278 see ``Scope of Externals'' in
3279 ``SCOPE RULES'' for the distinction between them.
3280 A function declarator is similar to a declarator
3281 for a ``function returning .\|.\|.\|'' except that
3282 it lists the formal parameters of
3283 the function being defined.
3285 \fIfunction-declarator:
3286         declarator ( parameter-list\v'0.5'\s-2opt\s0\v'-0.5' )
3289 \fIparameter-list:
3290         identifier
3291         identifier , parameter-list\fR
3294 The function-body
3295 has the form
3297 \fIfunction-body:
3298         declaration-list\v'0.5'\s-2opt\s0\v'-0.5' compound-statement\fR
3301 The identifiers in the parameter list, and only those identifiers,
3302 may be declared in the declaration list.
3303 Any identifiers whose type is not given are taken to be
3305 int\fR.
3307 The only storage class which may be specified is
3308 \fBregister\fR;
3309 if it is specified, the corresponding actual parameter
3310 will be copied, if possible, into a register
3311 at the outset of the function.
3313 A simple example of a complete function definition is
3315 \fBint max(a, b, c)
3316         int a, b, c;
3318         int m;
3320         m = (a > b) ? a : b;
3321         return((m > c) ? m : c);
3322 }\fR
3325 Here
3329 is the type-specifier;
3331 max(a,\ b,\ c)
3333 is the function-declarator;
3335 int\ a,\ b,\ c;
3337 is the declaration-list for
3338 the formal
3339 parameters;
3340 \fB{\ ...\ }\fR
3341 is the
3342 block giving the code for the statement.
3344 The C program converts all
3346 float
3348 actual parameters
3350 \fBdouble\fR,
3351 so formal parameters declared
3353 float
3355 have their declaration adjusted to read
3357 double\fR.
3359 All \fBchar\fR and \fBshort\fR formal parameter
3360 declarations are similarly adjusted
3361 to read \fBint\fR.
3362 Also, since a reference to an array in any context
3363 (in particular as an actual parameter)
3364 is taken to mean
3365 a pointer to the first element of the array,
3366 declarations of formal parameters declared ``array of .\|.\|.\|''
3367 are adjusted to read ``pointer to .\|.\|.\|.''
3368 .NH 2
3369 External Data Definitions
3371 An external data definition has the form
3373 \fIdata-definition:
3374         declaration\fR
3377 The storage class of such data may be
3379 extern
3381 (which is the default)
3384 static
3386 but not
3388 auto
3391 \fBregister\fR.
3392 .NH 1
3393 Scope Rules
3395 A C program need not all
3396 be compiled at the same time. The source text of the
3397 program
3398 may be kept in several files, and precompiled
3399 routines may be loaded from
3400 libraries.
3401 Communication among the functions of a program
3402 may be carried out both through explicit calls
3403 and through manipulation of external data.
3405 Therefore, there are two kinds of scopes to consider:
3406 first, what may be called the
3407 .UL lexical
3408 .UL scope
3409 of an identifier, which is essentially the
3410 region of a program during which it may
3411 be used without drawing ``undefined identifier''
3412 diagnostics;
3413 and second, the scope
3414 associated with external identifiers,
3415 which is characterized by the rule
3416 that references to the same external
3417 identifier are references to the same object.
3418 .NH 2
3419 Lexical Scope
3421 The lexical scope of identifiers declared in external definitions
3422 persists from the definition through
3423 the end of the source file
3424 in which they appear.
3425 The lexical scope of identifiers which are formal parameters
3426 persists through the function with which they are
3427 associated.
3428 The lexical scope of identifiers declared at the head of a block
3429 persists until the end of the block.
3430 The lexical scope of labels is the whole of the
3431 function in which they appear.
3433 In all cases, however,
3434 if an identifier is explicitly declared at the head of a block,
3435 including the block constituting a function,
3436 any declaration of that identifier outside the block
3437 is suspended until the end of the block.
3439 Remember also (see ``Structure, Union, and Enumeration Declarations'' in
3440 ``DECLARATIONS'') that tags, identifiers associated with
3441 ordinary variables,
3442 and identities associated with structure and union members
3443 form three disjoint classes
3444 which do not conflict.
3445 Members and tags follow the same scope rules
3446 as other identifiers.
3447 The \fBenum\fR constants are in the same
3448 class as ordinary variables and follow the same scope rules.
3451 typedef
3453 names are in the same class as ordinary identifiers.
3454 They may be redeclared in inner blocks, but an explicit
3455 type must be given in the inner declaration:
3457 \fBtypedef float distance;
3458 \&...
3460      auto int distance;
3461      ...\fR
3469 must be present in the second declaration,
3470 or it would be taken to be
3471 a declaration with no declarators and type
3473 distance\fR.
3475 .NH 2
3476 Scope of Externals
3478 If a function refers to an identifier declared to be
3479 \fBextern\fR,
3480 then somewhere among the files or libraries
3481 constituting the complete program
3482 there must be at least one external definition
3483 for the identifier.
3484 All functions in a given program which refer to the same
3485 external identifier refer to the same object,
3486 so care must be taken that the type and size
3487 specified in the definition
3488 are compatible with those specified
3489 by each function which references the data.
3491 It is illegal to explicitly initialize any external
3492 identifier more than once in the set of files and libraries
3493 comprising a multi-file program.
3494 It is legal to have more than one data definition
3495 for any external non-function identifier;
3496 explicit use of \fBextern\fR does not
3497 change the meaning of an external declaration.
3499 In restricted environments, the use of the \fBextern\fR
3500 storage class takes on an additional meaning.
3501 In these environments, the explicit appearance of the
3502 \fBextern\fR keyword in external data declarations of
3503 identities without initialization indicates that
3504 the storage for the identifiers is allocated elsewhere,
3505 either in this file or another file.
3506 It is required that there be exactly one definition of
3507 each external identifier (without \fBextern\fR)
3508 in the set of files and libraries
3509 comprising a mult-file program.
3511 Identifiers declared
3513 static
3515 at the top level in external definitions
3516 are not visible in other files.
3517 Functions may be declared
3519 static\fR.
3521 .nr Hu 1
3522 .NH 1
3523 Compiler Control Lines
3525 The C compiler contains a preprocessor capable
3526 of macro substitution, conditional compilation,
3527 and inclusion of named files.
3528 Lines beginning with
3532 communicate
3533 with this preprocessor.
3534 There may be any number of blanks and horizontal tabs
3535 between the \fB#\fR and the directive.
3536 These lines have syntax independent of the rest of the language;
3537 they may appear anywhere and have effect which lasts (independent of
3538 scope) until the end of the source program file.
3539 .nr Hu 1
3540 .NH 2
3541 Token Replacement
3543 A compiler-control line of the form
3545 \fB#define \fIidentifier token-string\v'0.5'\s-2opt\s0\v'-0.5'\fR
3548 causes the preprocessor to replace subsequent instances
3549 of the identifier with the given string of tokens.
3550 Semicolons in or at the end of the token-string are part of that string.
3551 A line of the form
3553 \fB#define \fIidentifier(identifier, ... )token-string\v'0.5'\s-2opt\s0\v'-0.5'\fR
3556 where there is no space between the first identifier
3557 and the
3558 \fB(\fR,
3559 is a macro definition with arguments.
3560 There may be zero or more formal parameters.
3561 Subsequent instances of the first identifier followed
3562 by a
3563 \fB(\fR,
3564 a sequence of tokens delimited by commas, and a
3565 \fB)\fR
3566 are replaced
3567 by the token string in the definition.
3568 Each occurrence of an identifier mentioned in the formal parameter list
3569 of the definition is replaced by the corresponding token string from the call.
3570 The actual arguments in the call are token strings separated by commas;
3571 however, commas in quoted strings or protected by
3572 parentheses do not separate arguments.
3573 The number of formal and actual parameters must be the same.
3574 Strings and character constants in the token-string are scanned
3575 for formal parameters, but
3576 strings and character constants in the rest of the program are
3577 not scanned for defined identifiers
3578 to replacement.
3580 In both forms the replacement string is rescanned for more
3581 defined identifiers.
3582 In both forms
3583 a long definition may be continued on another line
3584 by writing
3588 at the end of the line to be continued.
3590 This facility is most valuable for definition of ``manifest constants,''
3591 as in
3593 \fB#define TABSIZE 100
3595 int table\|[\|TABSIZE\|]\|;\fR
3598 A control line of the form
3600 \fB#undef \fIidentifier\fR
3603 causes the
3604 identifier's preprocessor definition (if any) to be forgotten.
3606 If a \fB#define\fRd identifier is the subject of a subsequent
3607 \fB#define\fR with no intervening \fB#undef\fR, then
3608 the two token-strings are compared textually.
3609 If the two token-strings are not identical
3610 (all white space is considered as equivalent), then
3611 the identifier is considered to be redefined.
3612 .nr Hu 1
3613 .NH 2
3614 File Inclusion
3616 A compiler control line of
3617 the form
3619 \fB#include\fI "filename\|\fR"
3622 causes the replacement of that
3623 line by the entire contents of the file
3625 filename\fR.
3627 The named file is searched for first in the directory
3628 of the file containing the \fB#include\fR,
3629 and then in a sequence of specified or standard places.
3630 Alternatively, a control line of the form
3632 \fB#include\fI <filename\|\fR>
3635 searches only the specified or standard places
3636 and not the directory of the \fB#include\fR.
3637 (How the places are specified is not part of the language.)
3639 \fB#include\fRs
3640 may be nested.
3641 .nr Hu 1
3642 .NH 2
3643 Conditional Compilation
3645 A compiler control line of the form
3647 \fB#if \fIrestricted-constant-expression\fR
3650 checks whether the restricted-constant expression evaluates to nonzero.
3651 (Constant expressions are discussed in ``CONSTANT EXPRESSIONS'';
3652 the following additional restrictions apply here:
3653 the constant expression may not contain
3655 sizeof
3657 casts, or an enumeration constant.)
3659 A restricted constant expression may also contain the
3660 additional unary expression
3662 \fBdefined \fIidentifier\fR
3666 \fBdefined( \fIidentifier )\fR
3668 which evaluates to one if the identifier is currently
3669 defined in the preprocessor and zero if it is not.
3671 All currently defined identifiers in restricted-constant-expressions
3672 are replaced by their token-strings (except those identifiers
3673 modified by \fBdefined\fR) just as in normal text.
3674 The restricted constant expression will be evaluated only
3675 after all expressions have finished.
3676 During this evaluation, all undefined (to the procedure)
3677 identifiers evaluate to zero.
3679 A control line of the form
3681 \fB#ifdef \fIidentifier\fR
3684 checks whether the identifier is currently defined
3685 in the preprocessor; i.e., whether it has been the
3686 subject of a
3688 #define
3690 control line.
3691 It is equivalent to \fB#ifdef(\fIidentifier\fB)\fR.
3692 A control line of the form
3694 \fB#ifndef \fIidentifier\fR
3697 checks whether the identifier is currently undefined
3698 in the preprocessor.
3699 It is equivalent to
3701 \fB#if  !\|defined(\fIidentifier\fB)\fR.
3704 All three forms are followed by an arbitrary number of lines,
3705 possibly containing a control line
3707 \fB#else\fR
3710 and then by a control line
3712 \fB#endif\fR
3715 If the checked condition is true,
3716 then any lines
3717 between
3719 #else
3723 #endif
3725 are ignored.
3726 If the checked condition is false, then any lines between
3727 the test and a
3729 #else
3731 or, lacking a
3732 \fB#else\fR,
3735 #endif
3737 are ignored.
3739 These constructions may be nested.
3740 .nr Hu 1
3741 .NH 2
3742 Line Control
3744 For the benefit of other preprocessors which generate C programs,
3745 a line of the form
3747 \fB#line \fIconstant "filename\fR"
3750 causes the compiler to believe, for purposes of error
3751 diagnostics,
3752 that the line number of the next source line is given by the constant and the current input
3753 file is named by "\fIfilename\fR".
3754 If "\fIfilename\fR" is absent, the remembered file name does not change.
3755 .nr Hu 1
3756 .NH 1
3757 Implicit Declarations
3759 It is not always necessary to specify
3760 both the storage class and the type
3761 of identifiers in a declaration.
3762 The storage class is supplied by
3763 the context in external definitions
3764 and in declarations of formal parameters
3765 and structure members.
3766 In a declaration inside a function,
3767 if a storage class but no type
3768 is given, the identifier is assumed
3769 to be
3770 \fBint\fR;
3771 if a type but no storage class is indicated,
3772 the identifier is assumed to
3775 auto\fR.
3777 An exception to the latter rule is made for
3778 functions because
3780 auto
3782 functions do not exist.
3783 If the type of an identifier is ``function returning .\|.\|.\|,''
3784 it is implicitly declared to be
3786 extern\fR.
3789 In an expression, an identifier
3790 followed by
3794 and not already declared
3795 is contextually
3796 declared to be ``function returning
3798 int\fR.''
3799 .nr Hu 1
3800 .NH 1
3801 Types Revisited
3803 This part summarizes the operations
3804 which can be performed on objects of certain types.
3805 .nr Hu 1
3806 .NH 2
3807 Structures and Unions
3809 Structures and unions may be assigned, passed as arguments to functions,
3810 and returned by functions.
3811 Other plausible operators, such as equality comparison
3812 and structure casts,
3813 are not implemented.
3815 In a reference
3816 to a structure or union member, the
3817 name on the right
3818 of the \fB->\fR or the \fB.\fR
3819 must specify a member of the aggregate
3820 named or pointed to by the expression
3821 on the left.
3822 In general, a member of a union may not be inspected
3823 unless the value of the union has been assigned using that same member.
3824 However, one special guarantee is made by the language in order
3825 to simplify the use of unions:
3826 if a union contains several structures that share a common initial sequence
3827 and if the union currently contains one of these structures,
3828 it is permitted to inspect the common initial part of any of
3829 the contained structures.
3830 For example, the following is a legal fragment:
3832 \fBunion
3834         struct
3835         {
3836                 int        type;
3837         } n;
3838         struct
3839         {
3840                 int        type;
3841                 int        intnode;
3842         } ni;
3843         struct
3844         {
3845                 int        type;
3846                 float      floatnode;
3847         } nf;
3848 } u;
3849 \&...
3850 u.nf.type = FLOAT;
3851 u.nf.floatnode = 3.14;
3852 \&...
3853 if (u.n.type == FLOAT)
3854         ... sin(u.nf.floatnode) ...\fR
3857 .nr Hu 1
3858 .NH 2
3859 Functions
3861 There are only two things that
3862 can be done with a function \fBm\fR,
3863 call it or take its address.
3864 If the name of a function appears in an
3865 expression not in the function-name position of a call,
3866 a pointer to the function is generated.
3867 Thus, to pass one function to another, one
3868 might say
3870 \fBint f();
3871 \&...
3872 g(f);\fR
3875 .ne 8
3876 Then the definition of
3880 might read
3882 \fBg(funcp)
3883         int (\(**funcp)();
3885         ...
3886         (\(**funcp)();
3887         ...
3888 }\fR
3891 Notice that
3895 must be declared
3896 explicitly in the calling routine since its appearance
3899 g(f)
3901 was not followed by
3905 .nr Hu 1
3906 .NH 2
3907 Arrays, Pointers, and Subscripting
3909 Every time an identifier of array type appears
3910 in an expression, it is converted into a pointer
3911 to the first member of the array.
3912 Because of this conversion, arrays are not
3913 lvalues.
3914 By definition, the subscript operator
3918 is interpreted
3919 in such a way that
3921 E1[E2]
3923 is identical to
3925 \(**((E1)\(plE2))\fR.
3927 Because of the conversion rules
3928 which apply to
3929 \fB\(pl\fR,
3934 is an array and
3938 an integer,
3939 then
3941 E1[E2]
3943 refers to the
3945 E2-th
3947 member of
3949 E1\fR.
3951 Therefore,
3952 despite its asymmetric
3953 appearance, subscripting is a commutative operation.
3955 A consistent rule is followed in the case of
3956 multidimensional arrays.
3961 is an
3962 \fIn\fR-dimensional
3963 array
3964 of rank
3965 i\(muj\(mu...\(muk,
3966 then
3970 appearing in an expression is converted to
3971 a pointer to an (n-1)-dimensional
3972 array with rank
3973 j\(mu...\(muk.
3974 If the
3976 \(**
3978 operator, either explicitly
3979 or implicitly as a result of subscripting,
3980 is applied to this pointer,
3981 the result is the pointed-to (n-1)-dimensional array,
3982 which itself is immediately converted into a pointer.
3984 For example, consider
3986 \fBint x[3][5];\fR
3989 Here
3993 is a 3\(mu5 array of integers.
3994 When
3998 appears in an expression, it is converted
3999 to a pointer to (the first of three) 5-membered arrays of integers.
4000 In the expression
4001 \fBx[i]\fR,
4002 which is equivalent to
4003 \fB\(**(x\(pli)\fR,
4007 is first converted to a pointer as described;
4008 then
4012 is converted to the type of
4013 \fBx\fR,
4014 which involves multiplying
4018 by the
4019 length the object to which the pointer points,
4020 namely 5-integer objects.
4021 The results are added and indirection applied to
4022 yield an array (of five integers) which in turn is converted to
4023 a pointer to the first of the integers.
4024 If there is another subscript, the same argument applies
4025 again; this time the result is an integer.
4027 Arrays in C are stored
4028 row-wise (last subscript varies fastest)
4029 and the first subscript in the declaration helps determine
4030 the amount of storage consumed by an array.
4031 Arrays play no other part in subscript calculations.
4032 .nr Hu 1
4033 .NH 2
4034 Explicit Pointer Conversions
4036 Certain conversions involving pointers are permitted
4037 but have implementation-dependent aspects.
4038 They are all specified by means of an explicit type-conversion
4039 operator, see ``Unary Operators'' under``EXPRESSIONS'' and
4040 ``Type Names''under ``DECLARATIONS.''
4042 A pointer may be converted to any of the integral types large
4043 enough to hold it.
4044 Whether an
4050 long
4052 is required is machine dependent.
4053 The mapping function is also machine dependent but is intended
4054 to be unsurprising to those who know the addressing structure
4055 of the machine.
4056 Details for some particular machines are given below.
4058 An object of integral type may be explicitly converted to a pointer.
4059 The mapping always carries an integer converted from a pointer back to the same pointer
4060 but is otherwise machine dependent.
4062 A pointer to one type may be converted to a pointer to another type.
4063 The resulting pointer may cause addressing exceptions
4064 upon use if
4065 the subject pointer does not refer to an object suitably aligned in storage.
4066 It is guaranteed that
4067 a pointer to an object of a given size may be converted to a pointer to an object
4068 of a smaller size
4069 and back again without change.
4071 For example,
4072 a storage-allocation routine
4073 might accept a size (in bytes)
4074 of an object to allocate, and return a
4076 char
4078 pointer;
4079 it might be used in this way.
4081 \fBextern char \(**malloc();
4082 double \(**dp;
4084 dp = (double \(**) malloc(sizeof(double));
4085 \(**dp = 22.0 / 7.0;\fR
4090 alloc
4092 must ensure (in a machine-dependent way)
4093 that its return value is suitable for conversion to a pointer to
4094 \fBdouble\fR;
4095 then the
4099 of the function is portable.
4101 The pointer
4102 representation on the
4103 PDP-11
4104 corresponds to a 16-bit integer and
4105 measures bytes.
4108 char\fR's
4109 have no alignment requirements; everything else must have an even address.
4111 On the
4112 VAX-11,
4113 pointers are 32 bits long and measure bytes.
4114 Elementary objects are aligned on a boundary equal to their
4115 length, except that
4117 double
4119 quantities need be aligned only on even 4-byte boundaries.
4120 Aggregates are aligned on the strictest boundary required by
4121 any of their constituents.
4123 The 3B 20 computer has 24-bit pointers placed into 32-bit quantities.
4124 Most objects are
4125 aligned on 4-byte boundaries. \fBShort\fRs are aligned in all cases on
4126 2-byte boundaries. Arrays of characters, all structures,
4127 \fBint\fR\^s, \fBlong\fR\^s, \fBfloat\fR\^s, and \fBdouble\fR\^s are aligned on 4-byte
4128 boundaries; but structure members may be packed tighter.
4129 .nr Hu 1
4130 .NH 2
4131 CONSTANT EXPRESSIONS
4133 In several places C requires expressions that evaluate to
4134 a constant:
4135 after
4136 \fBcase\fR,
4137 as array bounds, and in initializers.
4138 In the first two cases, the expression can
4139 involve only integer constants, character constants,
4140 casts to integral types,
4141 enumeration constants,
4144 sizeof
4146 expressions, possibly
4147 connected by the binary operators
4148 .ne 10
4150 \(pl \(mi \(** / % & | ^ << >> == != < > <= >= && ||
4153 or by the unary operators
4155 \(mi  \s+2~\s0
4158 or by the ternary operator
4163 Parentheses can be used for grouping
4164 but not for function calls.
4166 More latitude is permitted for initializers;
4167 besides constant expressions as discussed above,
4168 one can also use floating constants
4169 and arbitrary casts and
4170 can also apply the unary
4174 operator to external or static objects
4175 and to external or static arrays subscripted
4176 with a constant expression.
4177 The unary
4181 can also
4182 be applied implicitly
4183 by appearance of unsubscripted arrays and functions.
4184 The basic rule is that initializers must
4185 evaluate either to a constant or to the address
4186 of a previously declared external or static object plus or minus a constant.
4187 .nr Hu 1
4188 .NH 1
4189 Portability Considerations
4191 Certain parts of C are inherently machine dependent.
4192 The following list of potential trouble spots
4193 is not meant to be all-inclusive
4194 but to point out the main ones.
4196 Purely hardware issues like
4197 word size and the properties of floating point arithmetic and integer division
4198 have proven in practice to be not much of a problem.
4199 Other facets of the hardware are reflected
4200 in differing implementations.
4201 Some of these,
4202 particularly sign extension
4203 (converting a negative character into a negative integer)
4204 and the order in which bytes are placed in a word,
4205 are nuisances that must be carefully watched.
4206 Most of the others are only minor problems.
4208 The number of
4210 register
4212 variables that can actually be placed in registers
4213 varies from machine to machine
4214 as does the set of valid types.
4215 Nonetheless, the compilers all do things properly for their own machine;
4216 excess or invalid
4218 register
4220 declarations are ignored.
4222 Some difficulties arise only when
4223 dubious coding practices are used.
4224 It is exceedingly unwise to write programs
4225 that depend
4226 on any of these properties.
4228 The order of evaluation of function arguments
4229 is not specified by the language.
4230 The order in which side effects take place
4231 is also unspecified.
4233 Since character constants are really objects of type
4234 \fBint\fR,
4235 multicharacter character constants may be permitted.
4236 The specific implementation
4237 is very machine dependent
4238 because the order in which characters
4239 are assigned to a word
4240 varies from one machine to another.
4242 Fields are assigned to words and characters to integers right to left
4243 on some machines
4244 and left to right on other machines.
4245 These differences are invisible to isolated programs
4246 that do not indulge in type punning (e.g.,
4247 by converting an
4251 pointer to a
4253 char
4255 pointer and inspecting the pointed-to storage)
4256 but must be accounted for when conforming to externally-imposed
4257 storage layouts.
4258 .nr Hu 1
4259 .NH 1
4260 Syntax Summary
4262 This summary of C syntax is intended more for aiding comprehension
4263 than as an exact statement of the language.
4264 .nr Hu 1
4265 .ne 18
4266 .NH 2
4267 Expressions
4269 The basic expressions are:
4270 .tr ~~
4272      \fIexpression:
4273              primary
4274              \(** expression\fR
4275              &\fIlvalue
4276              \(mi expression
4277              ! expression
4278              \s+2~\s0 expression
4279              \(pl\(pl lvalue
4280              \(mi\(milvalue
4281              lvalue \(pl\(pl
4282              lvalue \(mi\(mi
4283              \fBsizeof\fI expression
4284              \fBsizeof (\fItype-name\fB)\fI
4285              ( type-name ) expression
4286              expression binop expression
4287              expression ? expression : expression
4288              lvalue asgnop expression
4289              expression , expression
4292      \fIprimary:
4293              identifier
4294              constant
4295              string
4296              ( expression )
4297              primary ( expression-list\v'0.5'\s-2opt\s0\v'-0.5' )
4298              primary [ expression ]
4299              primary . identifier
4300              primary \(mi identifier
4303      \fIlvalue:
4304              identifier
4305              primary [ expression ]
4306              lvalue . identifier
4307              primary \(mi identifier
4308              \(** expression
4309              ( lvalue )\fR
4313 The primary-expression operators
4315      ()  []  .  \(mi
4316 .tr ~~
4319 have highest priority and group left to right.
4320 The unary operators
4322      \(**  &  \(mi  !  \s+2~\s0  \(pl\(pl \(mi\(mi \fBsizeof\fI   ( type-name \fR)
4325 have priority below the primary operators
4326 but higher than any binary operator
4327 and group right to left.
4328 Binary operators
4329 group left to right; they have priority
4330 decreasing
4331 as indicated below.
4333      \fIbinop:\fR
4334              \(**    /    %
4335              \(pl    \(mi
4336              >>   <<
4337              <    >    <=    >=
4338              ==   !=
4339              &
4340              ^
4341              |
4342              &&
4343              ||
4345 The conditional operator groups right to left.
4347 Assignment operators all have the same
4348 priority and all group right to left.
4350      \fIasgnop:\fR
4351              =  \(pl=  \(mi=  \(**=  /=  %=  >>=  <<=  &=  ^=  |=
4354 The comma operator has the lowest priority and groups left to right.
4355 .nr Hu 1
4356 .NH 2
4357 Declarations
4360      \fIdeclaration:
4361              decl-specifiers init-declarator-list\v'0.5'\s-2opt\s0\v'-0.5' ;
4364      \fIdecl-specifiers:
4365              type-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
4366              sc-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
4369      \fIsc-specifier:\fB
4370              auto
4371              static
4372              extern
4373              register
4374              typedef
4377      \fItype-specifier:
4378              struct-or-union-specifier
4379              typedef-name
4380              enum-specifier
4381      basic-type-specifier:
4382              basic-type
4383              basic-type basic-type-specifiers
4384      basic-type:\fB
4385              char
4386              short
4387              int
4388              long
4389              unsigned
4390              float
4391              double
4392              void\fR
4395 \fIenum-specifier:\fB
4396              enum\fI { enum-list }\fB
4397              enum \fIidentifier { enum-list }\fB
4398              enum \fIidentifier
4401      \fIenum-list:
4402              enumerator
4403              enum-list , enumerator
4406      \fIenumerator:
4407              identifier
4408              identifier = constant-expression
4411      \fIinit-declarator-list:
4412              init-declarator
4413              init-declarator , init-declarator-list
4416      \fIinit-declarator:
4417              declarator initializer\v'0.5'\s-2opt\s0\v'-0.5'
4420      \fIdeclarator:
4421              identifier
4422              ( declarator )
4423              \(** declarator
4424              declarator ()
4425              declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]
4428      \fIstruct-or-union-specifier:\fB
4429              struct\fI { struct-decl-list }\fB
4430              struct \fIidentifier { struct-decl-list }\fB
4431              struct \fIidentifier\fB
4432              union { \fIstruct-decl-list }\fB
4433              union \fIidentifier { struct-decl-list }\fB
4434              union \fIidentifier
4437      \fIstruct-decl-list:
4438              struct-declaration
4439              struct-declaration struct-decl-list
4442      \fIstruct-declaration:
4443              type-specifier struct-declarator-list ;
4446      \fIstruct-declarator-list:
4447              struct-declarator
4448              struct-declarator , struct-declarator-list
4451      \fIstruct-declarator:
4452              declarator
4453              declarator : constant-expression
4454              : constant-expression
4457      \fIinitializer:
4458              = expression
4459              = { initializer-list }
4460              = { initializer-list , }
4463      \fIinitializer-list:
4464              expression
4465              initializer-list , initializer-list
4466              { initializer-list }
4467              { initializer-list , }
4470      \fItype-name:
4471              type-specifier abstract-declarator
4474      \fIabstract-declarator:
4475              empty
4476              ( abstract-declarator )
4477              \(** abstract-declarator
4478              abstract-declarator ()
4479              abstract-declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]
4482      \fItypedef-name:
4483              identifier
4484 .nr Hu 1
4486 .NH 2
4487 Statements
4490      \fIcompound-statement:
4491              { declaration-list\v'0.5'\s-2opt\s0\v'-0.5' statement-list\v'0.5'\s-2opt\s0\v'-0.5' }
4494      \fIdeclaration-list:
4495              declaration
4496              declaration declaration-list
4499      \fIstatement-list:
4500              statement
4501              statement statement-list
4504      \fIstatement:
4505              compound-statement
4506              expression ;
4507              \fBif\fI ( expression ) statement
4508              \fBif\fI ( expression ) statement  \fBelse\fI statement
4509              \fBwhile\fI ( expression ) statement
4510              \fBdo\fI statement  \fBwhile\fI ( expression ) ;
4511              \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
4512              \fBswitch\fI ( expression ) statement
4513              \fBcase\fI constant-expression :  statement
4514              \fBdefault\fI : statement
4515              \fBbreak ;
4516              continue ;
4517              return ;
4518              return\fI expression ;
4519              \fBgoto\fI identifier ;
4520              identifier : statement
4521              ;\fR
4522 .nr Hu 1
4524 .NH 2
4525 External definitions
4528      \fIprogram:
4529              external-definition
4530              external-definition program
4533      \fIexternal-definition:
4534              function-definition
4535              data-definition
4538      \fIfunction-definition:
4539              decl-specifier\v'0.5'\s-2opt\s0\v'-0.5' function-declarator function-body
4542      \fIfunction-declarator:
4543              declarator ( parameter-list\v'0.5'\s-2opt\s0\v'-0.5' )
4546      \fIparameter-list:
4547              identifier
4548              identifier , parameter-list
4551      \fIfunction-body:
4552              declaration-list\v'0.5'\s-2opt\s0\v'-0.5' compound-statement
4555      \fIdata-definition:
4556              \fBextern\fI declaration\fB ;
4557              \fBstatic\fI declaration\fB ;
4560 Preprocessor
4562              \fB#define\fI identifier token-string\v'0.3'\s-2opt\s0\v'-0.3'\fB
4563              \fB#define\fI identifier\fB(\fIidentifier\fB,...)\fItoken-string\v'0.5'\s-2opt\s0\v'-0.5'\fB
4564              \fB#undef\fI identifier\fB
4565              \fB#include "\fIfilename\|\fB"
4566              #include <\fIfilename\|\fB>
4567              \fB#if\fI restricted-constant-expression\fB
4568              \fB#ifdef\fI identifier\fB
4569              \fB#ifndef\fI identifier\fB
4570              \fB#else
4571              \fB#endif
4572              \fB#line\fI constant \fB"\fIfilename\|\fB"
4573 .sp 5
4575 .\" .TC 2 1 3 0