Jump to content

Cfront

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 138.246.7.170 (talk) at 09:02, 22 September 2008. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Cfront was the original compiler for C++ (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 language and much of the code was written via translations. Cfront had a complete parser, built symbol tables, and built a tree for each class, function, 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 System V derivatives without many changes, but BSD-based systems 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, however a compiler with similar approach became available later, namely Comeau C/C++, which is considered highly standard compliant.