At least I tried

At least I tried

So, it is possible to get CFront to work. I downloaded the 3.0.3 release, massaged the source a bit and compiled it on MacOS X. The output looks very close to what the Norcroft compiler generates, but it’s not close enough. And the reason is simple: The Norcroft compiler in the Newton C++ Tools is based on the 2.1 CFront release. Too bad, there is no source available for that. I guess this does not qualify as fun for many people, but maybe I get a degree in software archeology at some point… we’re talking about code which is 15-20 years old. No further comments about the quality of the CFront sources, they compiled after all, but looking at them is as much fun as poking a fork into your eye.

As a bit of background information, the main issue with C++ on the Newton is the incompatible vtable format: The Norcroft compiler does not handle multiple inheritance well as far as I can see, so it uses a quite simple vtable format, and all later compilers changed that somehow (either by using thunks or stubs, or by adding offset fields). Unfortunately, the vtable format has a direct influence on the generated code, calling virtual functions looks quite different from compiler to compiler. In addition to that, the vtables in the Newton ROM are actual jumps, whereas other compilers just use function addresses.

What will work though is to use C++ without virtual functions, and to stick with C.

2007-07-02