ecf_bdw@jhunix.UUCP (Dwight Wilson) (06/26/86)
In a previous article I wrote that one could use the macro: #define pointer_to(X) X * in order to allow declarations of the form pointer_to(float) x; There are a couple more things I would like to say about this. First, this will work on more complicated expressions, not just the basic types. For instance you could declare pointer_to(struct treenode { int nodelabel; pointer_to(struct treenode) right; pointer_to(struct treenode) left; }) head; this is the same as struct treenode { int nodelabel; struct treenode *right; struct treenode *left; } *head; Let's not get into an argument over which is better, I prefer the second form myself, but can easily understand why some people would like the first one. Finally, the use of this macro is not limited to declarations. Suppose we have defined the treenode structure as above. We could the write: newnode = (pointer_to(struct treenode)) malloc (sizeof (struct treenode)); instead of newnode = (struct treenode *) malloc (sizeof (struct treenode)); Again, which form to use is a matter of personal taste. -Dwight
aka@cbrma.UUCP (Andy Kashyap) (06/30/86)
In article <3082@jhunix.UUCP> ecf_bdw@jhunix.UUCP (Dwight Wilson) writes: > >In a previous article I wrote that one could use the macro: > > #define pointer_to(X) X * > >in order to allow declarations of the form > > pointer_to(float) x; > [ ...] > -Dwight Someday someone will try this declaration: pointer_to(int) pa, pb, pc ; and be in for a surprise. - Andy Kashyap - ..!cbosgd!cbrma!aka