Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!caip!brl-adm!brl-smoke!smoke!Schauble@MIT-MULTICS.ARPA From: Schauble@MIT-MULTICS.ARPA (Paul Schauble) Newsgroups: net.lang.c Subject: SWAP macro Message-ID: <1577@brl-smoke.ARPA> Date: Mon, 23-Jun-86 00:25:34 EDT Article-I.D.: brl-smok.1577 Posted: Mon Jun 23 00:25:34 1986 Date-Received: Tue, 24-Jun-86 05:14:20 EDT Sender: news@brl-smoke.ARPA Lines: 14 I've gotten lots of respones to my request for a form of the macro that would make swap(*a++, *b++); work. Almost all of them missed the point. The swap requires a temporary. Generating that temporary requires knowing the type. Several of the solutions would work fine if *a and *b were int's, but I never said that. Recall the my original message was posted as a justification for a typeof macro, akin to sizeof. I find that the need to generate temporaries in a macro is not uncommon. Unless one is willing to do a different version of the macro for each type, you need a way to generate a new variable of the same type as one of the macro args. The language provides no way to do this.