Typedefs in casts

utzoo!decvax!ittvax!bunker!kirk utzoo!decvax!ittvax!bunker!kirk
Fri Apr 1 10:00:48 AEST 1983


    Could someone please explain to me why the cast operator does
not know about typedefs.
    I recently had some code with the line

        foo = (ushort)((bar * constant) + bar2))

where ushort was a typedef for unsigned short, foo was defined as a ushort
and bar and bar2 were chars. The code compiled cleanly but at link 
time I got the error message

        undefined _ushort

A quick change to

        foo = (UCOUNT)((bar * constant) + bar2))

where UCOUNT is defined to be unsigned short compiles and links correctly.
Why is this so different to the error case.

(Please no flames about the use of casts, the code is not mine.)

Thanks, Dave Kirkpatrick



More information about the Comp.lang.c mailing list