Addressing struct without ->

Erik Naggum enag at ifi.uio.no
Mon Feb 4 09:37:37 AEST 1991


In article <10615 at jarthur.Claremont.EDU>, Derek R. Foster writes:
   In article <wolfram.665407476 at cip-s02>, Wolfram Roesler writes:
   >I'm not sure if the following will work:
   >
   >struct
   >{
   >  int foo;
   >  int bar;
   >} xyz;
   >#define foo xyz.foo
   >#define bar xyz.bar

   Probably not. You've created circular definitions of foo and bar with the
   preprocessor. ("foo" expands to "xyz.foo" which expands to "xyz.xyz.foo"
   ad infinitum.)

Only in some compilers.  ANSI C, most notably, disables expansion of
the macro name being defined in the body of the definition, as well as
in the expansion of macroes used in the definition.  Very handy.

--
When will "All the world's a VAX" be replaced by "All the world's ANSI C"?
--
[Erik Naggum]	Snail: Naggum Software / BOX 1570 VIKA / 0118 OSLO / NORWAY
		Mail: <erik at naggum.uu.no>, <enag at ifi.uio.no>
My opinions.	Wail: +47-2-836-863	Another int'l standards dude.



More information about the Comp.lang.c mailing list