Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!news.funet.fi!tukki.jyu.fi!jyu.fi!otto From: otto@tukki.jyu.fi (Otto J. Makela) Newsgroups: comp.lang.c Subject: Re: Cryptic code == Optimized code ? YES : NO ; Message-ID: Date: 27 Sep 90 17:18:12 GMT References: <861@gtenmc.UUCP>, <168@thor.UUCP> <2514@cirrusl.UUCP> Sender: news@tukki.jyu.fi (News articles) Organization: Turing Police, Criminal AI section Lines: 19 In-Reply-To: dhesi%cirrusl@oliveb.ATC.olivetti.com's message of 27 Sep 90 03:32:16 GMT In article <2514@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes: I have seen a "typeof" keyword proposed that would fix this deficieny: #define swap(a,b) do { typeof(a) tmp; tmp = a; a = b; b = tmp; } until (0); I don't believe this! I have the chance to correct Mr. Dhesi! The whole idea of having the do {...} while(0) [sic!] around the macro definition is to ensure rational behaviour of the macro (which to the unaided eye looks a lot like a function call) if invoked inside an if-then-else type structure, where adding an extra ';' could affect the syntactic interpretatiton. Thus, you DON'T use a ';' at the end of the macro. Actually, typeof() is not only proposed, it is implemented in gcc. -- /* * * Otto J. Makela * * * * * * * * * * * * * * * * * * */ /* Phone: +358 41 613 847, BBS: +358 41 211 562 (CCITT, Bell 24/12/300) */ /* Mail: Kauppakatu 1 B 18, SF-40100 Jyvaskyla, Finland, EUROPE */ /* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * * * * * */