typedef vs define

Wm E. Davidsen Jr davidsen at sixhub.UUCP
Sun Mar 18 07:03:42 AEST 1990


In article <82 at demott.COM> kdq at 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 at 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



More information about the Comp.lang.c mailing list