From owner-freebsd-current@FreeBSD.ORG Sun Jul 29 22:30:23 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 33F33106564A; Sun, 29 Jul 2012 22:30:23 +0000 (UTC) (envelope-from lacombar@gmail.com) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 65B208FC15; Sun, 29 Jul 2012 22:30:22 +0000 (UTC) Received: by wgbds11 with SMTP id ds11so4114842wgb.31 for ; Sun, 29 Jul 2012 15:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=onHD85A1m9eBg4hBaRW8BZcqj3Ppqz1bIAuhMZEI1Kw=; b=MEgu1qLhZ1V9/Ortru/QjO/HedYogDFLd4po3blRMdeueKY2//7t/Q6eG6Zl6b2H4x XiTsh0c4CwmqSRWlLQ7tlfBkv9uce7w0JOEqoLZT/Q1bepnHFMjrlOiO8InP2TN+KNVh 1DPAuN7V3RPbXtg5G9brsnb6gtHPGcwZed/iaYSJ/tk4InPqqdVhTteH3d3+sscDeCT0 m3LY/+UbW0VWmI1n/55z+tRl+GAY1Ffn6UlLqBizrBHVF5a5F7KySSBeJKqtfaQJ5wI8 CCA/50CuJ0dZ50DVcfVF4/fL+x1v4Pf0butX6uM/4Amw00/BhsTd0kwSQ0fAy5MBxotN 17eA== MIME-Version: 1.0 Received: by 10.216.86.74 with SMTP id v52mr4782249wee.4.1343601021295; Sun, 29 Jul 2012 15:30:21 -0700 (PDT) Received: by 10.216.199.31 with HTTP; Sun, 29 Jul 2012 15:30:21 -0700 (PDT) In-Reply-To: <1119098728.20120730003000@serebryakov.spb.ru> References: <20120725155211.GA33971@onelab2.iet.unipi.it> <20120729095833.GB80946@onelab2.iet.unipi.it> <20120729191958.GB85015@onelab2.iet.unipi.it> <20120729204721.GA87481@onelab2.iet.unipi.it> <1119098728.20120730003000@serebryakov.spb.ru> Date: Sun, 29 Jul 2012 18:30:21 -0400 Message-ID: From: Arnaud Lacombe To: lev@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "Bjoern A. Zeeb" , Luigi Rizzo , current@freebsd.org, David Chisnall Subject: Re: RFC: libkern version of inet_ntoa_r X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jul 2012 22:30:23 -0000 Hi, On Sun, Jul 29, 2012 at 4:30 PM, Lev Serebryakov wrote: > Hello, Luigi. > You wrote 30 =D0=B8=D1=8E=D0=BB=D1=8F 2012 =D0=B3., 0:47:21: > >>> #define fn(x) ({ fn(x, 42); }) > LR> nice trick, one always learns something on these lists... > LR> now i wonder how it works with MSVC (windows being one of the > LR> other platforms where i need to build the ipfw+dummynet code...) > It looks very gcc-ish. > could you back your point with a technical argument, please ? This sounds rather FUD'ish so far. The ({ ... }) is nothing more than a primary-expression enclosing a compound-statement; this part is not specifically necessary. As for the expansion, I would assume the following part of iso9899:1999 applies: << 6.10.3 Macro replacement 10 A preprocessing directive of the form # define identifier lparen identifier-listopt ) replacement-list new-line # define identifier lparen ... ) replacement-list new-line # define identifier lparen identifier-list , ... ) replacement-list new-lin= e defines a function-like macro with arguments, similar syntactically to a function call. [...] Each subsequent instance of the function-like macro name followed by a ( as the next preprocessing token introduces the sequence of preprocessing tokens that is replaced by the replacement list in the definition (an invocation of the macro). The replaced sequence of preprocessing tokens is terminated by the matching ) preprocessing token, [...] >> Note that the standard say "Each subsequent", no "All", so fn(1, 2); #define fn(a) fn(a, 2) fn(1); would produces: fn(1, 2); fn(1, 2); I do not see any gcc'ism here. Now, I might be wrong, and would enjoy being proven so. Thanks, - Arnaud