Pages

Sunday, April 6, 2014

ANSI C STANDARD


                Although K& R C had a rich set of features it was the initial version and C had a lot to grow. The [Kernighan and Ritchie 1978] was the reference manual for both the programmers and compiler writers for almost a decade. Since it is not meant for compiler writers, it left lot of ambiguity in its interpretation and many of the constructs were not clear. One such example is the list of library functions. Nothing significant is said about the header files in the [Kernighan and Ritchie 1978] and so each implementation had their own set of library functions. The compiler vendors had different interpretations and added more features (language extensions) of their own. This created many inconsistencies between the programs written for various compilers and lot of portability and efficiency problems cropped up.
To overcome the problem of inconsistency and standardize the available language features ANSI formed a committee called X3J11. Its primary aim was to make “an unambiguous and machine-independent definition of C” while still retaining the spirit of C. The committee made a research and submitted a document and that was the birth of ANSI C standard. Soon the ISO committee adopted the same standard with very little modifications and so it became an international standard. It came to be called as ANSI/ISO C standard or more popularly as just ANSI C standard.
                Even experienced C programmers also doesn’t know much about ANSI standard except what they frequently read or hear about what the standard says. When they get curious enough to go through the ANSI C document, they stumble a little to understand the document. The document is hard to understand by the programmers because it is meant for compiler writers and vendors ensures accuracy and describes the C language precisely. So the language used in the document is jocularly called as ‘standardese’. For example to describe side effects, the standard uses the idea of ‘sequence-points’ that may help confusing the reader more. L-value is not simply the ‘LHS (to =) value’. It is more properly a "locator value" designating an object.
            ANSI standard is not a panacea for all problems. To give an example, ANSI C widened the difference between the C used as a ‘high-level language’ and as ‘portable assembly language’. The original [Kernighan and Ritchie 1978] is more preferred even now by the various language compilers to generate C as their target language. Because it is less-typed than ANSI C. To give another example, many think ‘sequence-points’ fully describe side-effects and the belief that knowing its mechanism will help to fully understand side-effects. This is a false notion about sequence-points of [ANSI C 1989]. Sequence points doesn’t help fully understand side-effects.

Related Posts by Categories

0 comments:

Post a Comment