Cfront |
Cfront was the original Compiler for C plus plus (then known as C with Classes ) from around 1983, which converted C++ to C; developed by Bjarne Stroustrup. The preprocessor did not understand all of the programming language and much of the source code was written via translation (programming). Cfront had a complete parser, built symbol tables, and built a tree data structure for each class (computer science), function (programming), etc.
As Cfront was written in C++, it was a challenge to bootstrap on a machine without a C++ compiler/translator. Along with the Cfront C++ sources, a special half-preprocessed version of the C code resulting from compiling Cfront with itself was also provided. This C code was to be compiled with the native C compiler, and the resulting executable could then be used to compile the Cfront C++ sources.
Most of the porting effort in getting Cfront running on a new machine was related to standard I/O. Cfront s C++ streams were closely tied in with the C library s buffered I/O streams, but there was little interaction with the rest of the C environment. The compiler could be ported to most SysV derivatives without many changes, but BSD-based Unixen usually had much more variations in their C libraries and associated stdio structures.
Cfront defined the language until circa 1990, and many of the more obscure corner cases in C++ were related to its C++-to-C translation approach. A few remnants of Cfront s translation method are still found in today s C++ compilers; name mangling was originated by Cfront, as the relatively primitive linkers at the time did not support type information in symbols, and some template instantiation models are derived from Cfront s early efforts. C++ (and Cfront) was directly responsible for many improvements in Unix linkers and object file formats, as it was the first widely-used language which required link-time type checking, weak symbols, and other similar features.
Cfront 4.0 was abandoned after a failed attempt to add exception support, and it appears it is no longer commercially available. The C++ language had grown beyond its capabilities, and it is unlikely a similar translation effort would be 100% successful with the modern C++ standard. While it is possible to generate an equivalent C program for any given C++ program, the relative complexity of Standard C++ mandates a compiler capable of understanding the entire language rather than just the C++-specific constructs.|
|