Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.lang.c Subject: `interesting' program Message-ID: <2833@solo8.cs.vu.nl> Date: 7 Jul 89 04:03:20 GMT Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 64 ----------8<----------8<----------8<----------8<----------8<---------- /* Any comments? */ struct foo { int mids; }; struct foo zork() { struct foo foo; foo.mids = 79; return foo; } /* * Try: * cc -DFOO foo.c * cc -DBAR foo.c * cc foo.c * gcc -DFOO foo.c * gcc -DBAR foo.c * gcc foo.c * * and compare! */ main() { #if !FOO && !BAR struct foo bar; bar = zork(); #endif printf("%d\n", #if FOO zork().mids #else #if BAR (&zork())->mids #else bar.mids #endif #endif ); } ----------8<----------8<----------8<----------8<----------8<---------- Results: 1) Sun 3/50 w/ SunOS 3.5 cc dislikes FOO, likes BAR 2) Sun 3/50 w/ SunOS 3.5 gcc 1.32 likes FOO, dislikes BAR 3) Sun 4/280 w/ SunOS Sys4-3.2 cc likes FOO, likes BAR IMHO 2) is the winner! ISEHO 3) is right. I say: zork() is a constant of type struct foo, so you cannot take its address and it isn't an lvalue. SE says: zork() is the name of a struct foo, so you CAN take its address. -- "I HATE arbitrary limits, especially when |Maarten Litmaath @ VU Amsterdam: they're small." (Stephen Savitzky) |maart@cs.vu.nl, mcvax!botter!maart