[comp.lang.c] Compiling ANSI C on non-ANSI C environment

djones@megatest.UUCP (Dave Jones) (01/10/91)

From article <2865@hsi86.hsi.com>, by may@hsi86.hsi.com (Jeanette May):
> We are attempting to compile ANSI C source on 4.3 BSD UNIX (VAX)
> environment.

I'm wondering why there is seems to be no ANSI-C to C compiler around,
a la "cfront", the C++ to C compiler. It would seem to be a natural.
There are a couple of things that would have to be kluged up a little --
passing floats rather than doubles as parameters, for example -- but
that's no big deal.

Is there a market for such a beast? Is there one available? If not,
I'm sure I could rig one up without too much trouble.

gwyn@smoke.brl.mil (Doug Gwyn) (01/11/91)

In article <14824@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes:
>I'm wondering why there is seems to be no ANSI-C to C compiler around,
>a la "cfront", the C++ to C compiler. It would seem to be a natural.
>There are a couple of things that would have to be kluged up a little --
>passing floats rather than doubles as parameters, for example -- but
>that's no big deal.

First of all, the ANSI-C to C translator is called "cat" on UNIX systems.
Of course, what you really meant was a translator from standard C to some
flavor of pre-ANSI C; unfortunately there are numerous incompatible
dialects of the latter.  Even if you narrow that down to be "4.3BSD PCC's
dialect of C", the translation is by no means trivial -- a conforming
implementation would be about as difficult to obtain that way as writing
a genuine compiler.  It is not clear that a non-conforming attempt would
be worth all that much.

djones@megatest.UUCP (Dave Jones) (01/11/91)

The topic under consideration is a compiler from ANSI-C to
original C, ("C Classic"?), for those of us who have UNIX boxes
with C, but not the ANSI extensions and changes -- Sun workstations
in my case. I'm seeing more and more stuff on the net in ANSI-C, which
I cannot use easily, and it would be nice to have some of the features
for development work also, particularly prototypes.

So, what exactly are the tricky bits?

I mentioned passing floats (not doubles) to procedures. Ditto chars.
Raymond Chen reminded me of the ANSI rule against rearranging
floating-point expressions.

What else?