Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!uw-beaver!ubc-cs!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!quiche!utility From: utility@quiche.cs.mcgill.ca (Ronald BODKIN) Newsgroups: comp.lang.c Subject: macro inefficiency Message-ID: <5062@quiche.cs.mcgill.ca> Date: 27 Sep 90 16:18:09 GMT References: <168@thor.UUCP>> <2514@cirrusl.UUCP> Organization: SOCS - Mcgill University, Montreal, Canada Lines: 12 In article <2514@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes: [suggesting a swap macro with typeof:] >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); This should just be defined as: #define swap(a,b) { typeof(a) tmp; tmp = a; a = b; b = tmp; } (check out your C grammar carefully and you will see that { declaration* statement* } is always a valid statement). Ron