Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!unido!rwthinf!cip-s02!wolfram From: wolfram@cip-s02.informatik.rwth-aachen.de (Wolfram Roesler) Newsgroups: comp.lang.c Subject: Re: Addressing struct without -> Message-ID: Date: 1 Feb 91 11:24:36 GMT References: <91010.084408NIBMSCM@NDSUVM1.BITNET> Sender: news@rwthinf.UUCP Lines: 31 NIBMSCM@NDSUVM1.BITNET writes: > In working with some of the more common 'C' packages, I've found >one limiting factor that seems to come back and haunt me. In working >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). You can't get the same thing in C without getting ABSOLUTELY incompatible. You can however use the preprocessor trick to avoid long chains of -> and . in the following way: #define X ptr->fooptr->foo.bar.bar.baz.foobar->foobaz.x and now write X->something instead of (well you know what). I'm not sure if the following will work: struct { int foo; int bar; } xyz; #define foo xyz.foo #define bar xyz.bar