Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!axiom!humming!harvard!bu-cs!bzs From: bzs@bu-cs.UUCP (Barry Shein) Newsgroups: net.lang.c Subject: SWAP macro Message-ID: <857@bu-cs.UUCP> Date: Fri, 27-Jun-86 20:45:19 EDT Article-I.D.: bu-cs.857 Posted: Fri Jun 27 20:45:19 1986 Date-Received: Sun, 29-Jun-86 00:52:15 EDT Organization: Boston Univ Comp. Sci. Lines: 24 And then again, there's always this sort of thing (look in 4.2's /usr/include/sys/mbuf.h for a strong precedent): #define swap(x,y,t) { \ t *p1 = &(x), *p2 = &(y), tmp; \ \ tmp = *p1; \ *p1 = *p2; \ *p2 = tmp; \ } which is called with something like: swap(x,y,double); really not a bad thing (or is it too much bother for the programmer to know what type s/he is working with?) Still doesn't work with registers of course (but I don't think typeof() would solve that problem either.) Also, pointer types would have to be typedef'd to be useful as swap(x,y,char *) would not quite work (but w/ a typedef it works fine.) -Barry Shein, Boston University