Expert C Programming

(Jeff_L) #1

Software Dogma


Standards Are Set in Concrete, Even the Mistakes


Just because it's written down in an international standard doesn't mean that it's complete,
consistent, or even correct. The IEEE POSIX 1003.1-1988 standard (it's an OS standard that
defines UNIX-like behavior) has this fun contradiction:


"[A pathname] ... consists of at most PATH_MAX bytes, including the terminating null
character."—section 2.3


"PATH_MAX is the maximum number of bytes in a pathname (not a string length; count
excludes a terminating null)."—section 2.9.5


So PATH_MAX bytes both includes and does not include the terminating null!


An interpretation was requested, and the answer came back (IEEE Std 1003.1-1988/INT,
1992 Edition, Interpretation number: 15, p. 36) that it was an inconsistency and both can be
right (which is pretty strange, since the whole point is that both can't be right).


The problem arose because a change at the draft stage wasn't propagated to all occurrences
of the wording. The standards process is formal and rigid, so it cannot be fixed until an
update is approved by a balloting group.


This kind of error also appears in the C standard in the very first footnote, which refers to
the accompanying Rationale document. In fact, the Rationale no longer accompanies the C
Standard—it was deleted when ownership of the standard moved to ISO.


Handy Heuristic


Differences between K&R C and ANSI C


Rest assured that if you know K&R C, then you already know 90% of ANSI C. The
differences between ANSI C and K&R C fall into four broad categories, listed below in
order of importance:



  1. The first category contains things that are new, very different, and important. The
    only feature in this class is the prototype—writing the parameter types as part of

Free download pdf