Re: RFC: libkern version of inet_ntoa_r

看板FB_current作者時間13年前 (2012/07/30 15:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串17/17 (看更多)
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> _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
文章代碼(AID): #1G5ZXoRP (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1G5ZXoRP (FB_current)