Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: Addressing struct without ->
Message-ID: <1991Feb4.184742.6679@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <22711@netcom.UUCP>
Date: Mon, 4 Feb 1991 18:47:42 GMT

In article <22711@netcom.UUCP> avery@netcom.UUCP (Avery Colter) writes:
>>Can't be done (in any convenient way) in standard C.
>
>How about....
>#define element ptr->element
>for each element involved?

Works okay the first time, but the second time you have to #undef them
all first.  Or if you leave the macros alone and change ptr, either you
have to declare ptr in every function or you have to make it global,
which tends to reduce efficiency (notably because it interferes with
putting it into a register).  It's clumsy at best.  Also, to be portable
to old compilers you have to use different names to avoid macro recursion.
-- 
"Maybe we should tell the truth?"      | Henry Spencer at U of Toronto Zoology
"Surely we aren't that desperate yet." |  henry@zoo.toronto.edu   utzoo!henry
