typedef laxity

00704a-Liber nevin1 at ihlpf.ATT.COM
Thu Apr 7 10:58:09 AEST 1988


In article <1070 at maynard.BSW.COM> campbell at maynard.BSW.COM (Larry Campbell) writes:
>It seems to me someone should complain about this code:
>
>	typedef int TEMPERATURE;
>	typedef int PRESSURE;
>
>	TEMPERATURE tx, ty;
>	PRESSURE px, py;
>
>	ty = py;		/* type clash */
>
>But none of the compilers I've tested (pcc, VAX-11 C, Wang VS C, Turbo C)
>complain about it, and, even worse, _lint_ doesn't complain!

Someone IS complaining about this code:  you!  Remember, this is C, not
Pascal :-)!  This is perfectly legitimate C code, since:

"typedef does not introduce brand new types, only synonyms for types which
could be specified in another way."  (K&R 1, C Reference Manual, section
8.8.  Almost the same wording appears in section 3.5.6 of dpANS).

Since this is perfectly legal, I don't want my compiler to complain about
it.

>Does anyone know of a lint or compiler that will complain about it?
>Does anyone disagree that lint's silence in this case is a bug?
>(Especially since lint does complain about mixing enum types...)

I'm not sure how you could mix enum types within C's scoping rules, so this
should always be flagged as an *error* (correct me via email if I'm wrong
about this, though).

Now, if you want lint to issue a warning about mixing typedefs, it's fine
by me (since I don't use them very often).  But please make sure that a
flag to lint is provided to turn these warnings off.
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah



More information about the Comp.lang.c mailing list