Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!labrea!rocky!andy From: andy@rocky.STANFORD.EDU (Andy Freeman) Newsgroups: comp.lang.c Subject: typeof isn't enough to define swap correctly Message-ID: <557@rocky.STANFORD.EDU> Date: Fri, 4-Sep-87 14:36:13 EDT Article-I.D.: rocky.557 Posted: Fri Sep 4 14:36:13 1987 Date-Received: Sat, 5-Sep-87 18:35:55 EDT Reply-To: andy@rocky.UUCP (Andy Freeman) Organization: Stanford University Computer Science Department Lines: 19 In article <1354@dataio.Data-IO.COM>, bright@dataio.Data-IO.COM (Walter Bright) writes: > ... One thing I want, which the committee always seems to poo-poo, is a > typeof. Having a typeof would make creation of 'generic' routines possible: > #define swap(a,b) { typeof(a) tmp; tmp = a; a = b; b = tmp; } Even given typeof, this definition of swap is buggy. (It has at least two bugs.) I've never figured out how to define a C swap macro that works - I'm willing to believe it is impossible. Anyone have a use for typeof that isn't doesn't have the major bug that the swap macro defined above has? -andy -- Andy Freeman UUCP: {arpa gateways, decwrl, sun, hplabs, rutgers}!sushi.stanford.edu!andy ARPA: andy@sushi.stanford.edu (415) 329-1718/723-3088 home/cubicle