[comp.lang.c] typedef vs define

kdq@demott.COM (Kevin D. Quitt) (03/17/90)

    Sorry to bring up (belch) this subject again, but we have a
disagreement here over which to use.  Rather than just make my choice by
fiat, I prefer to be able to back it up. 

    Someone posted on this subject a very clear eaxmple of things that
could be done with typedefs that couldn't be done with defines.  Would
that someone mind sending me that example? Or anyone else with ideas one
way or another? Just to keep the heat to a minimum, might I suggest that
responses come email instead of posted? Thanks in advance. 

kdq
-- 

Kevin D. Quitt                          Manager, Software Development
DeMott Electronics Co.                  VOICE (818) 988-4975
14707 Keswick St.                       FAX   (818) 997-1190
Van Nuys, CA  91405-1266                MODEM (818) 997-4496 Telebit PEP last
34 12 N  118 27 W                       srhqla!demott!kdq   kdq@demott.com

  "Next time, Jack, write a God-damned memo!" - Jack Ryan - Hunt for Red Oct.

davidsen@sixhub.UUCP (Wm E. Davidsen Jr) (03/18/90)

In article <82@demott.COM> kdq@demott.COM (Kevin D. Quitt) writes:

|     Someone posted on this subject a very clear eaxmple of things that
| could be done with typedefs that couldn't be done with defines.  

  I don't have it handy, but here are a few.

typedef int *IPTR;		/* all items will be pointer to int */

typedef int SVECT[5];		/* type "array length five of int" */

  A define won't allow you to do those so you could say:

IPTR dmo1, *dmo2, dmo3[5];

SVECT xmpl1, *xmpl2, *xmpl3[5];
-- 
bill davidsen - davidsen@sixhub.uucp (uunet!crdgw1!sixhub!davidsen)
    sysop *IX BBS and Public Access UNIX
    moderator of comp.binaries.ibm.pc
"Getting old is bad, but it beats the hell out of the alternative" -anon