Mainstream D Programming

Peter C. Chapin pchapin at sover.net
Sun Oct 14 19:31:09 PDT 2007


Christopher Wright wrote:

> Peter C. Chapin wrote:
>> A D2C compiler would probably have to be written in C to be effective.
> 
> No it doesn't, you just write it in D and compile it with itself, and
> Bob's your uncle.

That's a good point, although I suppose you'd still have to port the run
time support libraries (which would necessarily be in C) to the new
platform before you could use the freshly compiled D2C over there.

So to be clear. Platform A is the development platform, and B is the
place were we would like to compile D programs but can't. We have the
source code for D2C, a D to C translator, written in D.

1. Compile D2C on platform A using a native D compiler. The result is a
program that converts D to C on platform A.

2. On platform A, compile D2C with the result of step #1 above. The
result is the C version of D2C.

3. Copy the result of step #2 to platform B.

4. Use the native C compiler on platform B to compile the C code copied
in step #3. The result is an executable version of D2C on platform B.

Of course the C code produced by D2C will probably need runtime support
in the form of a C library (so that it can be handled by the native C
compiler). This library will probably have some platform specific stuff
in it, and so would need to be ported manually before step #4 could be
done. That probably wouldn't be a huge deal, but I'm sure it would
depend on the platforms involved.

Sounds good. Who wants to write it? :-)

Peter



More information about the Digitalmars-d mailing list