Date: Wed, 6 Jun 2018 09:53:21 -0700 From: Conrad Meyer <cem@freebsd.org> To: Benjamin Kaduk <bjkfbsd@gmail.com>, Ravi Pokala <rpokala@freebsd.org> Cc: src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r334702 - head/sys/sys Message-ID: <CAG6CVpWBwK-6ALhhcDpe4jrr52j9oMWjdheDRABHauiRFDE13A@mail.gmail.com> In-Reply-To: <CAJ5_RoALt_%2BASNN5E2wBch-CEn0sesJO=1Z2aJsz1EwsesdFiQ@mail.gmail.com> References: <201806060508.w56586c9053686@repo.freebsd.org> <6E6E92B2-7536-4281-8EAF-72823E84902E@panasas.com> <CAJ5_RoALt_%2BASNN5E2wBch-CEn0sesJO=1Z2aJsz1EwsesdFiQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Ben, Ravi, GCC/Clang are fine with the just curly braces, or just do/while(0). The core benefit of the ({ }) syntax is to allow multiple-statement macros to have expression syntax externally (i.e., yield a value) =E2=80=94 which is not possible in standard C due to concession to simplistic parsers. Ben's link is a good one and does cover this in more detail. The URL ("Statement-Exprs") is a hint ;-). Best, Conrad On Wed, Jun 6, 2018 at 4:40 AM, Benjamin Kaduk <bjkfbsd@gmail.com> wrote: > On Wed, Jun 6, 2018 at 6:35 AM, Ravi Pokala <rpokala@freebsd.org> wrote: >> >> Hi Mateusz, >> >> =EF=BB=BF-----Original Message----- >> From: <owner-src-committers@freebsd.org> on behalf of Mateusz Guzik >> <mjg@FreeBSD.org> >> Date: 2018-06-06, Wednesday at 01:08 >> To: <src-committers@freebsd.org>, <svn-src-all@freebsd.org>, >> <svn-src-head@freebsd.org> >> Subject: svn commit: r334702 - head/sys/sys >> >> > ... >> > #ifdef _KERNEL >> > #define malloc(size, type, flags) ({ >> > \ >> >> Now that I'm taking another look at this, I'm confused as to why the >> entire macro expansion is inside parentheses? (The braces make sense, si= nce >> this is a block with local variables which need to be contained.) > > > This is a gcc (and clang) extension to allow the macro body to be a code > block -- standard C gets unhappy with just the curly braces. > https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html is a maybe-releva= nt > page that google found me. > > -Ben
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpWBwK-6ALhhcDpe4jrr52j9oMWjdheDRABHauiRFDE13A>