Date: Mon, 30 Jul 2012 11:12:09 +0400 From: Lev Serebryakov <lev@FreeBSD.org> To: Arnaud Lacombe <lacombar@gmail.com> Cc: "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>, Luigi Rizzo <rizzo@iet.unipi.it>, current@freebsd.org, David Chisnall <theraven@freebsd.org> Subject: Re: RFC: libkern version of inet_ntoa_r Message-ID: <492266872.20120730111209@serebryakov.spb.ru> In-Reply-To: <CACqU3MUZJH2FcWbYL0UBNwhztQRtY%2Bsk-ZGxywgg43pFe4ZyRw@mail.gmail.com> References: <20120725155211.GA33971@onelab2.iet.unipi.it> <alpine.BSF.2.00.1207282213171.4474@ai.fobar.qr> <20120729095833.GB80946@onelab2.iet.unipi.it> <CBCC6E24-8D03-422E-B571-1B62FB7667E6@FreeBSD.org> <20120729191958.GB85015@onelab2.iet.unipi.it> <CACqU3MVNCOdde7atRVT7xaYH1qHjm=4uS0Eih8EgG3=DDaOGCw@mail.gmail.com> <20120729204721.GA87481@onelab2.iet.unipi.it> <1119098728.20120730003000@serebryakov.spb.ru> <CACqU3MUZJH2FcWbYL0UBNwhztQRtY%2Bsk-ZGxywgg43pFe4ZyRw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hello, Arnaud. You wrote 30 =D0=B8=D1=8E=D0=BB=D1=8F 2012 =D0=B3., 2:30:21: >> It looks very gcc-ish. AL> could you back your point with a technical argument, please ? This AL> sounds rather FUD'ish so far. AL> The ({ ... }) is nothing more than a primary-expression enclosing a AL> compound-statement; And how will it return value? It is completely illegal for compound statement to return value. And to be a part of primary expression, too. Here is simple test: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1 #include <stdlib.h> 2 #include <stdio.h> 3 4 int fn(int x, int y) { return x + y; } 5 6 #define fn(x) ({ fn(x, 42); }) 7 8 int main(int argc, char *argv[]) { 9 printf("%d\n", fn(10)); 10 return 0; 11 } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D gcc compiles it and prints "52", but MSVC++ 10.0 cannot compile this at all, and it is in its own right: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D D:\home\lev\test>cl test.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 8= 0x86 Copyright (C) Microsoft Corporation. All rights reserved. test.c test.c(9) : error C2059: syntax error : '{' test.c(9) : error C2059: syntax error : ')' test.c(9) : error C2059: syntax error : ')' test.c(10) : error C2059: syntax error : 'return' test.c(11) : error C2059: syntax error : '}' =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D See http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html -- it is clearly marked as "GNU C" construct, not ANSI/ISO C/C++ one. And even more: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > gcc -Wall -ansi -pedantic -std=3Dc99 test.c test.c: In function 'main': test.c:9: warning: ISO C forbids braced-groups within expressions > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 // Black Lion AKA Lev Serebryakov <lev@FreeBSD.org>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?492266872.20120730111209>