Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!cbosgd!ihnp4!cuae2!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.lang.c,net.bugs Subject: Re: e1?(void_e2):(void_e3) so, is it legal or what? Message-ID: <1133@ttrdc.UUCP> Date: Sat, 16-Aug-86 15:21:50 EDT Article-I.D.: ttrdc.1133 Posted: Sat Aug 16 15:21:50 1986 Date-Received: Mon, 18-Aug-86 01:11:20 EDT References: <155@cbnap.UUCP> <499@dg_rtp.UUCP> <518@hadron.UUCP> <243@desint.UUCP> <1061@dataio.UUCP> Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 41 Xref: watmath net.lang.c:10272 net.bugs:877 In article <1061@dataio.UUCP>, bright@dataio.UUCP (Walter Bright) writes: >#define biff(pow) ((pow) ? kayo() : oof()) > >Defining the macro as: > >#define biff(pow) if (pow) kayo(); else oof(); > >causes difficulties with constructs like: > > if (socko) > biff(flez); > else > bang(glurp); > >Similar problems exist for the other permutations of defining biff(). Presuming that void kayo(), oof(); is intended, whatsa matter with #define biff(pow) { if (pow) kayo(); else oof(); } This combines the if-else into one single statement. There is a slight handicap that this doesn't work too well as the first operand of the comma operator ("syntax error") but at least some common modern C compilers (as on the SV 3B20) don't like Bright's macro either in this context or for that matter in any other context ("operands of : have incompatible types"). O.K., Bright (and others) have been saying "change the definition of C to allow this." Well I say the same thing about my suggestion, so THERE! :-) -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, go for it! allegra,ulysses,vax135}!ttrdc!levy