macro inefficiency

Ronald BODKIN utility at quiche.cs.mcgill.ca
Fri Sep 28 02:18:09 AEST 1990


In article <2514 at cirrusl.UUCP> dhesi%cirrusl at 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



More information about the Comp.lang.c mailing list