Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!ncar!gatech!mcnc!rti!xyzzy!meissner From: meissner@xyzzy.UUCP (Michael Meissner) Newsgroups: comp.lang.c Subject: Re: typedef laxity Message-ID: <757@xyzzy.UUCP> Date: 7 Apr 88 17:22:57 GMT References: <1070@maynard.BSW.COM> Reply-To: meissner@xyzzy.UUCP (Michael Meissner) Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 25 Keywords: typedef lint In article <1070@maynard.BSW.COM> campbell@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! | | 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...) Actually if they complain about it, they are not following either K&R or the ANSI draft, which quite clearly says that typedefs do NOT create a new type, rather all it does is create a synonym for an existing type. I've heard that the Microsoft 4.00 (and presumably 5.00) C does this with a compiler option. Another way to get the protection is to use C++ and declare the types to be a class (instead of a typedef). -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner Arpa/Csnet: meissner@dg-rtp.DG.COM