Introduction


C Standard · Amendments · Railroad-Track Diagrams · Notation


``Standard C'' is a term with a fairly precise definition. This document supplies that definition. It also describes the notation used throughout this description of Standard C.

C Standard

The Standard C programming language described in this document corresponds to the American National Standards Institute (ANSI) standard for the C language -- ANSI X3.159-1989. An identical standard was approved by the International Organization for Standardization (ISO) -- ISO/IEC 9899:1990. This common standard was developed through the joint efforts of the ANSI-authorized C Programming Language Committee X3J11 and the ISO authorized Committee JTC1 SC22 WG14.

Standard C is designed to ``codify existing practice.'' Most of the C code written before the advent of Standard C is still acceptable to one or more Standard C translators. Nevertheless, Standard C is a new language:

This document presents Standard C as a distinct language, not as a historical outgrowth of any particular earlier dialect of C. If you are new to C or are familiar with just a specific dialect, you have a new language to learn.

Amendments

The C Standard has more recently been amended and clarified. Amendment 1 (approved in 1994) adds extensive support for manipulating wide characters, which represent large character sets, and some additional support for writing source code in national variants of the ISO 646 character set. Most of these new features are additions to the library, and most library additions are defined or declared in three new headers -- <iso646.h>, <wchar.h>, and <wctype.h>. Many Standard C translators have yet to add these new features, so this document labels such additions as new with Amendment 1. For maximum near-term portability, you may wish to avoid them.

Technical Corrigendum 1 (also approved in 1994) supplies a number of clarifications and corrections to the C Standard. These are in response to ANSI Requests for Interpretation or ISO Defect Reports received and processed by X3J11 and WG14 since the C Standard was first issued. None are intended to alter the original definition of Standard C, merely to make its definition more unambiguous and precise. This document reflects the effect of Technical Corrigendum 1, but does not identify any specific changes.

Railroad-Track Diagrams

Syntax rules appear in the form of railroad-track diagrams. The diagrams summarize all valid ways that you can form explicit computer text for a given form. Not all forms that you can generate from a railroad-track diagram are necessarily valid. Often semantic restrictions also apply. These are described in separate tables or in running text.

A railroad-track diagram contains boxes that indicate the components you use to create a form. Arrows connect the boxes to indicate the ways that you can combine the components. You can create different text for a form by taking different paths between the boxes. The name of the form appears next to the arrow leading out to the right from the diagram.

Here, for example, is the syntax rule for writing a name in Standard C:

You generate a valid name by following the arrows. Begin with the arrow leading in from the left and continue until you follow the arrow leading out to the right. In a complex diagram, an arrow followed by an ellipsis (...) connects to the arrow preceded by an ellipsis immediately below.

Each time you come to a box, you must add the text in the box to the item being created. If the box contains a form, you must add text that matches the form. If the box contains more than one entry, you must add one of the choices. If you come to an intersection with two arrows leading away from it, you can follow either arrow. You cannot follow an arrow in the direction opposite to the way it points.

The railroad-track diagram above tells you:

A name can therefore be any of the following:

A       A3      _x
timer   box_2   z173ab
an_extremely_long_name_that_also_contains_1_digit

The syntax rule does not tell you about the following semantic limitations:

Some diagrams require boxes that permit anything except one or a few items. In these cases, bold text describes the matching rule. For example, not NL matches any character except a newline character.

Notation

A type face that differs from the running text has a special meaning:

digit  0 1 2 3 4 5 6 7 8 9

See also the Table of Contents and the Index.

Copyright © 1989-1996 by P.J. Plauger and Jim Brodie. All rights reserved.