Addressing struct without ->

Avery Colter avery at netcom.UUCP
Mon Feb 4 08:59:53 AEST 1991


Henry Spencer writes:
>In article <91010.084408NIBMSCM at NDSUVM1.BITNET> NIBMSCM at NDSUVM1.BITNET writes:
>>with some other languages, such as Pascal, I had the capability to use
>>the 'using' keyword, giving the address of a structure and then address
>>the elements of that structure without the necessity of using the
>>ptr->element notation (could simply use element).
>>  Could anyone out there tell me how I can implement this in 'C' ...

>Can't be done (in any convenient way) in standard C.

How about....

#define element ptr->element

for each element involved?

Then, in the program itself, use ptr as a dummy, assigning it to
point to whichever structure is appropos.

-- 
Avery Ray Colter    {apple|claris}!netcom!avery  {decwrl|mips|sgi}!btr!elfcat
(415) 839-4567   "I feel love has got to come on and I want it:
                  Something big and lovely!"         - The B-52s, "Channel Z"



More information about the Comp.lang.c mailing list