Addressing struct without ->
Henry Spencer
henry at zoo.toronto.edu
Tue Feb 5 05:47:42 AEST 1991
In article <22711 at netcom.UUCP> avery at 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 at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list