Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Thu, 5 Apr 2001 13:39:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Thu, 5 Apr 2001 13:39:40 -0400 Received: from jalon.able.es ([212.97.163.2]:1764 "EHLO jalon.able.es") by vger.kernel.org with ESMTP id ; Thu, 5 Apr 2001 13:39:29 -0400 Date: Thu, 5 Apr 2001 19:38:40 +0200 From: "J . A . Magallon" To: Andreas Schwab Cc: Joseph Carter , Bart Trojanowski , "'linux-kernel @ vger . kernel . org'" Subject: Re: asm/unistd.h Message-ID: <20010405193840.A5365@werewolf.able.es> In-Reply-To: <20010405072628.C22001@debian.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT In-Reply-To: ; from schwab@suse.de on Thu, Apr 05, 2001 at 16:45:44 +0200 X-Mailer: Balsa 1.1.3 Lines: 62 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On 04.05 Andreas Schwab wrote: > > Try this and watch your compiler complaining: > > #define foo() { } > #define bar() do { } while (0) > void mumble () > { > if (1) foo(); else bar(); > if (2) bar(); else foo(); > } > Perhaps it is time to USE gcc, yet the kernel can be built only with gcc. IE, use statement expressions. Try this: #define foo() ({ }) #define bar() do { } while (0) void mumble () { if (1) foo(); else bar(); if (2) bar(); else foo(); } and see you compiler shutup. You can even declare vars inside the ({ ... }) block, so all the #define bar(x) do { use_1(x); use_2(x); } while (0) could be written like: #define bar(x) ({ use_1(x); use_2(x); }) Even you can use : #define swap(a,b) \ ({ typeof(a) tmp = a; \ a = b; \ b = tmp; \ }) int main() { int a,b; double c,d; swap(a,b); swap(c,d); } Its correct in egcs-1.1.2 and up, so it is safe for use in kernel 2.4. Do not know if previuous gcc eats it up. -- J.A. Magallon # Let the source mailto:jamagallon@able.es # be with you, Luke... Linux werewolf 2.4.3-ac3 #1 SMP Thu Apr 5 00:28:45 CEST 2001 i686 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/