This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Style and Conventions: Multi-line function-like macro formatting.
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Zack Weinberg <zackw at panix dot com>
- Cc: Carlos O'Donell <carlos at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 18 Jan 2018 18:43:54 +0000
- Subject: Re: Style and Conventions: Multi-line function-like macro formatting.
- Authentication-results: sourceware.org; auth=none
- References: <bdeb4a74-ffeb-6906-d582-f6540de5a2b1@redhat.com> <alpine.DEB.2.20.1801181651070.16200@digraph.polyomino.org.uk> <CAKCAbMggNHo9P5jNT-YOZUmkXU8t+D3J9Tavv9bvrDJDC=56Qw@mail.gmail.com>
On Thu, 18 Jan 2018, Zack Weinberg wrote:
> I would put it stronger: ({ ... }) is a GCC extension that should be
> _avoided_ unless absolutely necessary, when neither a do { ... } while
> (0) block inside a macro nor an inline function will do the job.
I don't see it as a problematic extension, in cases where you do want the
value returned by the sequence of statements inside ({ }). Preferring
inline functions applies generically for anything that can readily be
expressed as an inline function rather than a macro - they're better than
both ({ }) and do { } while (0) in the cases where they work.
--
Joseph S. Myers
joseph@codesourcery.com