typedef vs #define

Andrew P. Mullhaupt amull at Morgan.COM
Wed Feb 28 06:01:53 AEST 1990


In article <24495 at princeton.Princeton.EDU>, nfs at notecnirp.Princeton.EDU (Norbert Schlenker) writes:
! 
! But beware.  If we change the question only slightly, to:
! Consider the following two C statements:
!  	typedef short * FLAGS
!  	#define FLAGS short *
! 
! Now there's a considerable difference between the two.  Imagine the
! declaration:
! 
! FLAGS x, y;
! 
! The typedef results in (probably) what people expect, namely that both
! x and y are pointers to short int.  The #define makes x a FLAGS and y
! a short, probably not what you want.

I clearly pointed out this distinction in the quote I gave from K&R2
in my posting. Did only a fragment get all the way over the net?

Also: I am posting this because I can't get mail to you...

Later,
Andrew Mullhaupt



More information about the Comp.lang.c mailing list