The C Standard
One of the biggest milestones for C was the completion of the standardization process. After the creation of the standard, which involved many people from several countries, there is a single set of features that is supported across C compilers in the market.
Before standardization, different vendors could, sometimes out of necessity, implement variations of the C language. For this reason, unexpected variations were present in the different compilers during the first years of the development of C. As a result, it was much harder to create C programs that would run on different machines, or even in the same machine but on distinct compilers. This became even more common with the proliferation of operating systems based on UNIX, which happened in the early 80s.
After the creation of the ANSI C standard, most of the compatibility issues have been solved, at least at a basic level. With enough care, it is nowadays possible to write C programs that will run unchanged in most of the computing platforms currently available.
The C standard is comprehensive, but simple, as is the language itself. It describes only the basic mechanisms available to all C programs, such as the lexical and syntactical conventions, the pre-processor and the signature of the main function, for example.
The standard also defines a rich set of basic libraries that are made available to any program that might decide to use them. The standard C library is composed of functions and data structures to perform operations such as input and output to files and the terminal, memory management, string manipulation, and mathematical operations, among others.
The set of standard libraries is available to programmers by using the #include directive. After a library is included, the program gains access to the desired subset of functionality.
Another important reason to know about the C standard is understanding that there are still some extensions provided by particular compiler vendors that are not supported in other environments. Such practices are usually done for the sake of convenience to users, but they can also be dangerous if used in code that might one day be ported to other platforms. The compiler documentation will usually point out what the platform specific extensions are, so that the programmers will be aware of the portability issues when using that feature. While it might be tempting to use a feature that can save some work now, it is always important to consider the need to compile that code in another environment. Since it is frequently hard to determine the importance of a piece of code as it is being written, the general advice is to avoid vendor-specific extensions whenever possible.
More recently, by the end of the nineties, a new standardization effort called C99 was created to add more modern features that were felt to be lacking in the language. For example, a boolean data type was added to simplify the manipulation of logical values. Additionally, variables can now be declared in any position where statements may appear, instead of only at the beginning of a block, as it was before C99.
Despite some clear advantages of C99, it is still not as widely supported as the traditional ANSI-C. Part of the reason is that many of the features introduced in C99 are already available in C++, and therefore users and vendors felt that they don’t need these features immediately implemented in their C code. It is expected, however, that newer versions of C compilers will gradually add support to all the features described in the C99 standard, and it is therefore a good measure the be aware of the differences.
Similar Posts:
About the Author
Carlos Oliveira holds a PhD in Systems Engineering and Optimization from University of Florida. He works as a software engineer, with more than 10 years of experience in developing high performance, commercial and scientific applications in C++, Java, and Objective-C. His most Recent Book is Practical C++ Financial Programming.
Sorry, comments for this entry are closed at this time.