Declaration puzzler (C as intermediate code)

David Chase chase at Ozona.orc.olivetti.com
Thu Oct 13 11:28:01 AEST 1988


In article <717 at wsccs.UUCP> dharvey at wsccs.UUCP (David Harvey) writes:
>In article <30091 at oliveb.olivetti.com>, chase at orc.olivetti.com (David Chase) writes:
>> 	typedef foo *(foo[10]);
>minds want to know.  Seriously, what do you intend to use this type of
>structure for?  An array of arrays that point to themselves?  Hmm,
>methinks I smell some mischief.

Well, you could call it mischief.  In the interests of having a
compiler for Modula-3 that is easy to port, we're generating C.  The
justification is that since it is possible to declare such an type in
Modula-3, and we are compiling Modula-3, then we must generate some
declaration for it (much as I am tempted, it is not considered good
form for a compiler to offer snide comments on legal programs).  I was
cheerfully spitting out declarations for all sorts of things, but had
a problem involving arrays.  The problem eventually reduced itself to
the example which I presented.  I got pretty PO'd, and posted (I know,
Ms. Net-manners says not do to that; allow me an occasional slip).

As a workaround, we are wrapping all arrays up inside structures.
This also gets us proper semantics for array assignment and parameter
passing, so it isn't too much of a disaster.  However, doing this
makes me distinctly uneasy about the correctness/portability of
addressing arithmetic performed for (multi-dimensional) open arrays.
Ugh.

By the way, anyone out there that thinks that C is a great
intermediate language should think again.  I was going to flame at
length, but decided not to.

David



More information about the Comp.lang.c mailing list