1 \." $Id: crefman.doc,v 1.5 1994/06/24 10:01:51 ceriel Exp $
2 .\" eqn crefman.doc | troff -ms
14 Department of Mathematics and Computer Science
23 This section discusses the extensions to and deviations from the C language,
25 The issues are numbered according to the reference manual.
29 Upper and lower case letters are different.
30 The number of significant letters
31 is 32 by default, but may be set to another value using the \fB\-M\fP option.
32 The identifier length should be set according to the rest of the compilation
39 The keyword \f(CWasm\fP
41 However, the statement
47 is skipped, while a warning is given.
51 The \f(CWenum\fP keyword is recognized and interpreted.
53 \f(CWentry\fP, \f(CWfortran\fP
55 The words \f(CWentry\fP and \f(CWfortran\fP
56 are reserved under the restricted option.
57 The words are not interpreted by the compiler.
59 2.4.1 Integer Constants
61 The type of an integer constant is the first of the corresponding list
62 in which its value can be represented. Decimal: \f(CWint, long, unsigned long\fP;
63 octal or hexadecimal: \f(CWint, unsigned, long, unsigned long\fP; suffixed by
64 the letter L or l: \f(CWlong, unsigned long\fP.
66 2.4.3 Character Constants
68 A character constant is a sequence of 1 up to \f(CWsizeof(int)\fP characters
69 enclosed in single quotes.
70 The value of a character constant '$c sub 1 c sub 2 ... c sub n$'
71 is $d sub n + M \(mu d sub {n - 1} + ... + M sup {n - 1} \(mu d sub 2 + M sup n \(mu d sub 1$,
72 where M is 1 + maximum unsigned number representable in an \f(CWunsigned char\fP,
73 and $d sub i$ is the signed value (ASCII)
74 of character $c sub i$.
76 2.4.4 Floating Constants
78 The compiler does not support compile-time floating point arithmetic.
80 2.6 Hardware characteristics
82 The compiler is capable of producing EM code for machines with the following
85 a \f(CWchar\fP is 8 bits
87 the size of \f(CWint\fP is equal to the word size
89 the size of \f(CWshort\fP may not exceed the size of \f(CWint\fP
91 the size of \f(CWint\fP may not exceed the size of \f(CWlong\fP
93 the size of pointers is equal to the size of either \f(CWshort\fP, \f(CWint\fP
101 Objects of type \f(CWchar\fP are taken to be signed.
102 The combination \f(CWunsigned char\fP is legal.
106 The type combinations \f(CWunsigned char\fP, \f(CWunsigned short\fP and
107 \f(CWunsigned long\fP are supported.
111 The data type \f(CWenum\fP is implemented as described
112 in \fIRecent Changes to C\fP (see appendix A).
114 treats enumeration variables as if they were \f(CWint\fP.
118 Type \f(CWvoid\fP is implemented.
119 The type specifies an empty set of values, which takes no storage space.
121 \fRFundamental types\fP
123 The names of the fundamental types can be redefined by the user, using
128 The order of evaluation of expressions depends on the complexity of the
130 In case of commutative operations, the most complex subexpression is
132 Parameter lists are evaluated from right to left.
136 The type of a \f(CWsizeof\fP expression is \f(CWunsigned int\fP.
138 7.13 Conditional operator
140 Both the second and the third expression in a conditional expression may
141 include assignment operators.
142 They may be structs or unions.
144 7.14 Assignment operators
146 Structures may be assigned, passed as arguments to functions, and returned
148 The types of operands taking part must be the same.
152 The combinations \f(CWunsigned char\fP, \f(CWunsigned short\fP
153 and \f(CWunsigned long\fP are implemented.
155 8.5 Structure and union declarations
157 Fields of any integral type, either signed or unsigned,
158 are supported, as long as the type fits in a word on the target machine.
160 Fields are left adjusted by default; the first field is put into the left
161 part of a word, the next one on the right side of the first one, etc.
162 The \f(CW-Vr\fP option in the call of the compiler
163 causes fields to be right adjusted within a machine word.
165 The tags of structs and unions occupy a different name space from that of
166 variables and that of member names.
170 The type of \fIexpression\fP in
173 \f(CWswitch (\fP\fIexpression\fP\f(CW)\fP \fIstatement\fP
177 A warning is given under the restricted option if the type is \f(CWlong\fP.
179 10 External definitions
181 See [4] for a discussion on this complicated issue.
183 10.1 External function definitions
185 Structures may be passed as arguments to functions, and returned
190 Typedef names may be redeclared like any other variable name; the ice mentioned
191 in \(sc11.1 is walked correctly.
193 12 Compiler control lines
195 Lines which do not occur within comment, and with \f(CW#\fP as first
196 character, are interpreted as compiler control line.
197 There may be an arbitrary number of spaces, tabs and comments (collectively
198 referred as \fIwhite space\fP) following the \f(CW#\fP.
199 Comments may contain newline characters.
200 Control lines with only white space between the \f(CW#\fP and the line separator
203 The #\f(CWinclude\fP, #\f(CWifdef\fP, #\f(CWifndef\fP, #\f(CWundef\fP, #\f(CWelse\fP and
204 #\f(CWendif\fP control lines and line directives consist of a fixed number of
206 The list of arguments may be followed an arbitrary sequence of characters,
207 in which comment is interpreted as such.
208 (I.e., the text between \f(CW/*\fP and \f(CW*/\fP is skipped, regardless of
209 newlines; note that commented-out lines beginning with \f(CW#\fP are not
210 considered to be control lines.)
212 12.1 Token replacement
214 The replacement text of macros is taken to be a string of characters, in which
215 an identifier may stand for a formal parameter, and in which comment is
217 Comments and newline characters, preceeded by a backslash, in the replacement
218 text are replaced by a space character.
220 The actual parameters of a macro are considered tokens and are
221 balanced with regard to \f(CW()\fP, \f(CW{}\fP and \f(CW[]\fP.
222 This prevents the use of macros like
229 Formal parameters of a macro must have unique names within the formal-parameter
232 A message is given at the definition of a macro if the macro has
233 already been #\f(CWdefined\fP, while the number of formal parameters differ or
234 the replacement texts are not equal (apart from leading and trailing
237 Recursive use of macros is detected by the compiler.
239 Standard #\f(CWdefined\fP macros are
241 \f(CW__FILE__\fP name of current input file as string constant
242 \f(CW__DATE__\fP curent date as string constant; e.g. \f(CW"Tue Wed 2 14:45:23 1986"\fP
243 \f(CW__LINE__\fP current line number as an integer
246 No message is given if \fIidentifier\fP is not known in
249 #undef \fIidentifier\fP
255 A newline character is appended to each file which is included.
257 12.3 Conditional compilation
259 The #\f(CWif\fP, #\f(CWifdef\fP and #\f(CWifndef\fP control lines may be followed
260 by an arbitrary number of
263 #elif \fIconstant-expression\fP
266 control lines, before the corresponding #\f(CWelse\fP or #\f(CWendif\fP
271 #elif \fIconstant-expression\fP
273 #endif /* corresponding to #elif */
280 #if \fIconstant-expression\fP
282 #endif /* corresponding to #if */
283 #endif /* corresponding to #else */
287 The \fIconstant-expression\fP in #\f(CWif\fP and #\f(CWelif\fP control lines
288 may contain the construction
291 defined(\fIidentifier\fP)
294 which is replaced by \f(CW1\fP, if \fIidentifier\fP has been #\f(CWdefined\fP,
295 and by \f(CW0\fP, if not.
297 Comments in skipped lines are interpreted as such.
301 Line directives may occur in the following forms:
305 #line \fIconstant\fP "\fIfilename\fP"
307 #\fIconstant\fP "\fIfilename\fP"
310 Note that \fIfilename\fP is enclosed in double quotes.
314 If a pointer to a function is called, the function the pointer points to
317 15 Constant expressions
319 The compiler distinguishes the following types of integral constant expressions
321 field-width specifier
327 global variable initialization value
331 truth value in \f(CW#if\fP control line
334 Constant integral expressions are compile-time evaluated while an effort
335 is made to report overflow.
336 Constant floating expressions are not compile-time evaluated.
340 Run the preprocessor stand-alone while maintaining the comments.
341 Line directives are produced whenever needed.
342 .IP \fB\-D\fP\fIname\fP=\fIstring-of-characters\fP
344 Define \fIname\fR as macro with \fIstring-of-characters\fR as
346 .IP \fB\-D\fP\fIname\fP
348 Equal to \fB\-D\fP\fIname\fP\fB=1\fP.
350 Run the preprocessor stand alone, i.e.,
351 list the sequence of input tokens and delete any comments.
352 Line directives are produced whenever needed.
355 Prepend \fIpath\fR to the list of include directories.
356 To put the directories "include", "sys/h" and "util/h" into the
357 include directory list in that order, the user has to specify
360 -Iinclude -Isys/h -Iutil/h
363 An empty \fIpath\fP causes the standard include
364 directory (usually \f(CW/usr/include\fP) to be forgotten.
367 Set maximum significant identifier length to \fIn\fP.
369 Suppress EM register messages.
370 The user-declared variables are not stored into registers on the target
373 Generate the EM \fBfil\fP and \fBlin\fP instructions in order to enable
374 an interpreter to keep track of the current location in the source code.
376 Equivalent with \fB\-E\fP, but without line directives.
378 Interpret the input as restricted C (according to the language as
380 .IP \fB\-T\fP\fIpath\fP
382 Create temporary files, if necessary, in directory \fIpath\fP.
383 .IP \fB\-U\fP\fIname\fP
385 Get rid of the compiler-predefined macro \fIname\fP, i.e.,
392 to appear in the beginning of the file.
393 .IP \fB\-V\fIcm\fR.\fIn\fR,\ \fB\-V\fIcm\fR.\fIncm\fR.\fIn\fR\ ...
395 Set the size and alignment requirements.
396 The letter \fIc\fR indicates the simple type, which is one of
397 \fBs\fR(short), \fBi\fR(int), \fBl\fR(long), \fBf\fR(float), \fBd\fR(double)
399 If \fIc\fR is \fBS\fP or \fBU\fP, then \fIn\fP is taken to be the initial
400 alignment of structs or unions, respectively.
401 The effective alignment of a struct or union is the least common multiple
402 of the initial struct/union alignment and the alignments of its members.
403 The \fIm\fR parameter can be used to specify the length of the type (in bytes)
404 and the \fIn\fR parameter for the alignment of that type.
405 Absence of \fIm\fR or \fIn\fR causes the default value to be retained.
406 To specify that the bitfields should be right adjusted instead of the
407 default left adjustment, specify \fBr\fR as \fIc\fR parameter.
409 Suppress warning messages
410 .IP \fB\-\-\fIcharacter\fR
412 Set debug-flag \fIcharacter\fP.
413 This enables some special features offered by a debug and develop version of
415 Some particular flags may be recognized, others may have surprising effects.
418 Generate a dependency graph, reflecting the calling structure of functions.
422 DFA: \fIcalling-function\fP: \fIcalled-function\fP
425 are generated whenever a function call is encountered.
427 Dump whole identifier table, including macros and reserved words.
429 Supply hash-table statistics.
431 Print names of included files.
433 Supply statistics concerning the memory allocation.
435 Dump table of identifiers.
437 Generate extra statistics concerning the predefined types and identifiers.
438 Works in combination with \fBf\fP or \fBt\fP.
440 Print expression trees in human-readable format.
446 Brian W. Kernighan, Dennis M. Ritchie,
448 The C Programming Language
453 Draft Proposed Standard - Programming Language C,
455 ANSI X3J11 Language Subcommittee
457 Erik H. Baalbergen, Dick Grune, Maarten Waage,
461 Informatica Manual IM-4, Dept. of Mathematics and Computer Science, Vrije
462 Universiteit, Amsterdam, The Netherlands
466 Modeling global declarations in C,
472 Appendix A - Enumeration Type
479 \&\f(CWenum\fP { \fIenum-list\fP }
481 \&\f(CWenum\fP \fIidentifier\fP { \fIenum-list\fP }
483 \&\f(CWenum\fP \fIidentifier\fP
490 \&\fIenum-list\fP , \fIenumerator\fP
497 \&\fIidentifier\fP = \fIconstant-expression\fP
501 The identifier has the same role as the structure tag in a struct specification.
502 It names a particular enumeration type.
504 The identifiers in the enum-list are declared as constants, and may appear
505 whenever constants are required.
506 If no enumerators with
508 appear, then the values of the constants begin at 0 and increase by 1 as the
509 declaration is read from left to right.
512 gives the associated identifier the value indicated; subsequent identifiers
513 continue the progression from the assigned value.
515 Enumeration tags and constants must all be distinct, and, unlike structure
516 tags and members, are drawn from the same set as ordinary identifiers.
518 Objects of a given enumeration type are regarded as having a type distinct
519 from objects of all other types.
522 Appendix B: C grammar in LL(1) form
524 The \fBbold-faced\fP and \fIitalicized\fP tokens represent terminal symbols.
527 \fBexternal definitions\fP
528 program: external-definition*
529 external-definition: ext-decl-specifiers [declarator [function | non-function] | '\fB;\fP'] | asm-statement
530 ext-decl-specifiers: decl-specifiers?
531 non-function: initializer? ['\fB,\fP' init-declarator]* '\fB;\fP'
532 function: declaration* compound-statement
535 declaration: decl-specifiers init-declarator-list? '\fB;\fP'
536 decl-specifiers: other-specifier+ [single-type-specifier other-specifier*]? | single-type-specifier other-specifier*
537 other-specifier: \fBauto\fP | \fBstatic\fP | \fBextern\fP | \fBtypedef\fP | \fBregister\fP | \fBshort\fP | \fBlong\fP | \fBunsigned\fP
538 type-specifier: decl-specifiers
539 single-type-specifier: \fItype-identifier\fP | struct-or-union-specifier | enum-specifier
540 init-declarator-list: init-declarator ['\fB,\fP' init-declarator]*
541 init-declarator: declarator initializer?
542 declarator: primary-declarator ['\fB(\fP' formal-list ? '\fB)\fP' | arrayer]* | '\fB*\fP' declarator
543 primary-declarator: identifier | '\fB(\fP' declarator '\fB)\fP'
544 arrayer: '\fB[\fP' constant-expression? '\fB]\fP'
545 formal-list: formal ['\fB,\fP' formal]*
547 enum-specifier: \fBenum\fP [enumerator-pack | identifier enumerator-pack?]
548 enumerator-pack: '\fB{\fP' enumerator ['\fB,\fP' enumerator]* '\fB,\fP'? '\fB}\fP'
549 enumerator: identifier ['\fB=\fP' constant-expression]?
550 struct-or-union-specifier: [ \fBstruct\fP | \fBunion\fP] [ struct-declaration-pack | identifier struct-declaration-pack?]
551 struct-declaration-pack: '\fB{\fP' struct-declaration+ '\fB}\fP'
552 struct-declaration: type-specifier struct-declarator-list '\fB;\fP'?
553 struct-declarator-list: struct-declarator ['\fB,\fP' struct-declarator]*
554 struct-declarator: declarator bit-expression? | bit-expression
555 bit-expression: '\fB:\fP' constant-expression
556 initializer: '\fB=\fP'? initial-value
557 cast: '\fB(\fP' type-specifier abstract-declarator '\fB)\fP'
558 abstract-declarator: primary-abstract-declarator ['\fB(\fP' '\fB)\fP' | arrayer]* | '\fB*\fP' abstract-declarator
559 primary-abstract-declarator: ['\fB(\fP' abstract-declarator '\fB)\fP']?
564 | label '\fB:\fP' statement
580 expression-statement: expression '\fB;\fP'
582 if-statement: \fBif\fP '\fB(\fP' expression '\fB)\fP' statement [\fBelse\fP statement]?
583 while-statement: \fBwhile\fP '\fB(\fP' expression '\fB)\fP' statement
584 do-statement: \fBdo\fP statement \fBwhile\fP '\fB(\fP' expression '\fB)\fP' '\fB;\fP'
585 for-statement: \fBfor\fP '\fB(\fP' expression? '\fB;\fP' expression? '\fB;\fP' expression? '\fB)\fP' statement
586 switch-statement: \fBswitch\fP '\fB(\fP' expression '\fB)\fP' statement
587 case-statement: \fBcase\fP constant-expression '\fB:\fP' statement
588 default-statement: \fBdefault\fP '\fB:\fP' statement
589 break-statement: \fBbreak\fP '\fB;\fP'
590 continue-statement: \fBcontinue\fP '\fB;\fP'
591 return-statement: \fBreturn\fP expression? '\fB;\fP'
592 jump: \fBgoto\fP identifier '\fB;\fP'
593 compound-statement: '\fB{\fP' declaration* statement* '\fB}\fP'
594 asm-statement: \fBasm\fP '\fB(\fP' \fIstring\fP '\fB)\fP' '\fB;\fP'
597 initial-value: assignment-expression | initial-value-pack
598 initial-value-pack: '\fB{\fP' initial-value-list '\fB}\fP'
599 initial-value-list: initial-value ['\fB,\fP' initial-value]* '\fB,\fP'?
600 primary: \fIidentifier\fP | constant | \fIstring\fP | '\fB(\fP' expression '\fB)\fP'
601 secundary: primary [index-pack | parameter-pack | selection]*
602 index-pack: '\fB[\fP' expression '\fB]\fP'
603 parameter-pack: '\fB(\fP' parameter-list? '\fB)\fP'
604 selection: ['\fB.\fP' | '\fB\->\fP'] identifier
605 parameter-list: assignment-expression ['\fB,\fP' assignment-expression]*
606 postfixed: secundary postop?
607 unary: cast unary | postfixed | unop unary | size-of
608 size-of: \fBsizeof\fP [cast | unary]
609 binary-expression: unary [binop binary-expression]*
610 conditional-expression: binary-expression ['\fB?\fP' expression '\fB:\fP' assignment-expression]?
611 assignment-expression: conditional-expression [asgnop assignment-expression]?
612 expression: assignment-expression ['\fB,\fP' assignment-expression]*
613 unop: '\fB*\fP' | '\fB&\fP' | '\fB\-\fP' | '\fB!\fP' | '\fB~ \fP' | '\fB++\fP' | '\fB\-\-\fP'
614 postop: '\fB++\fP' | '\fB\-\-\fP'
615 multop: '\fB*\fP' | '\fB/\fP' | '\fB%\fP'
616 addop: '\fB+\fP' | '\fB\-\fP'
617 shiftop: '\fB<<\fP' | '\fB>>\fP'
618 relop: '\fB<\fP' | '\fB>\fP' | '\fB<=\fP' | '\fB>=\fP'
619 eqop: '\fB==\fP' | '\fB!=\fP'
620 arithop: multop | addop | shiftop | '\fB&\fP' | '\fB^ \fP' | '\fB|\fP'
621 binop: arithop | relop | eqop | '\fB&&\fP' | '\fB||\fP'
622 asgnop: '\fB=\fP' | '\fB+\fP' '\fB=\fP' | '\fB\-\fP' '\fB=\fP' | '\fB*\fP' '\fB=\fP' | '\fB/\fP' '\fB=\fP' | '\fB%\fP' '\fB=\fP'
623 | '\fB<<\fP' '\fB=\fP' | '\fB>>\fP' '\fB=\fP' | '\fB&\fP' '\fB=\fP' | '\fB^ \fP' '\fB=\fP' | '\fB|\fP' '\fB=\fP'
624 | '\fB+=\fP' | '\fB\-=\fP' | '\fB*=\fP' | '\fB/=\fP' | '\fB%=\fP'
625 | '\fB<<=\fP' | '\fB>>=\fP' | '\fB&=\fP' | '\fB^=\fP' | '\fB|=\fP'
626 constant: \fIinteger\fP | \fIfloating\fP
627 constant-expression: assignment-expression
628 identifier: \fIidentifier\fP | \fItype-identifier\fP