Type checking for typedef's (new feature)

Henk Hesselink henk at ace.UUCP
Sun Jun 1 18:02:17 AEST 1986


In article <361 at batcomputer.TN.CORNELL.EDU> garry%cadif-oak at cu-arpa.cs.cornell.edu.arpa writes:

> I am reminded of a long-standing pet peeve of mine: I can get
> type-checking on structures and unions. I can get type-checking
> on primitive types (int, float, ...). I CANNOT get type-checking
> on datatypes declared via 'typedef' EXCEPT in terms of their underlying
> types. (I assume this all is still true in the new language standard.)
> 
> 
> Is it reasonable? Is it hard to implement? Comments?.

It is certainly reasonable, a little more type-checking in C would not
be at all amiss, but:

"It must be emphasised that a typedef declaration does not create a
new type in any sense" (K&R, page 141).

The problem is that typedefs get converted back to basic types fairly
early on in pass 1 of pcc (which, plus derivatives thereof, constitutes
a sizeable chunk of all C compilers), while serious type-checking is
mostly done in pass 2.  This means 1) letting pcc1 keep typedefs intact,
2) augmenting the intermediate code to allow this kind of information
to be specified and 3) getting pcc2 to do something useful with it.
Hard to implement?  Depends on where you stand, but certainly not some-
thing you'd hack up in an afternoon.

--
Henk Hesselink
ACE Associated Computer Experts bv.
Amsterdam, The Netherlands



More information about the Comp.lang.c mailing list