Type checking: shouldn't lint/cc complain?
Ken Turkowski
ken at turtlevax.UUCP
Mon Oct 15 11:11:36 AEST 1984
> Let's say I have the following C program:
>
> typedef int FOO ;
> typedef int BAR ;
> #define XXX (FOO) 1
> main() {
> BAR fff ;
> fff = XXX ;
> }
>
> When I run lint or cc on this program (on 4.1BSD or 4.2BSD), I
> get no complaints about the fact that fff is a variable of type
> BAR and it is being assigned a value of type FOO. Now I wouldn't
> want the C compiler to crap out on this code (as Pascal probably
> would with the equivalent program), but shouldn't the compiler
> (or at least lint) complain about this?
I agree that the compiler or lint should complain. Otherwise there's
no advantage to using a typedef over a #define.
--
Ken Turkowski @ CADLINC, Palo Alto, CA
UUCP: {amd,decwrl,flairvax,nsc}!turtlevax!ken
ARPA: turtlevax!ken at DECWRL.ARPA
More information about the Comp.lang.c
mailing list