Date: Sun, 25 Feb 2018 07:18:35 -0700 From: Alan Somers <asomers@freebsd.org> To: Dimitry Andric <dim@freebsd.org> Cc: src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r329910 - head/sys/cddl/contrib/opensolaris/uts/common/sys Message-ID: <CAOtMX2jg3JXEk9Wbq%2Bu_%2Bke%2BFGdL=8piRvGG_yC3ySnxHmXDiA@mail.gmail.com> In-Reply-To: <CBCA3200-19B8-4FCF-8581-918C762D594D@FreeBSD.org> References: <201802241601.w1OG1LQ3043733@repo.freebsd.org> <CBCA3200-19B8-4FCF-8581-918C762D594D@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Feb 25, 2018 at 6:52 AM, Dimitry Andric <dim@freebsd.org> wrote: > On 24 Feb 2018, at 17:01, Alan Somers <asomers@freebsd.org> wrote: > > > > Author: asomers > > Date: Sat Feb 24 16:01:21 2018 > > New Revision: 329910 > > URL: https://svnweb.freebsd.org/changeset/base/329910 > > > > Log: > > Implement CTASSERT using _Static_assert > > > > Prevents warnings about "unused typedef" with GCC-6 > > > > Reported by: GCC-6 > > MFC after: 18 days > > X-MFC-With: 329722 > > > > Modified: > > head/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h > > > > Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h > > ============================================================ > ================== > > --- head/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h Sat Feb > 24 15:13:20 2018 (r329909) > > +++ head/sys/cddl/contrib/opensolaris/uts/common/sys/debug.h Sat Feb > 24 16:01:21 2018 (r329910) > > @@ -133,8 +133,8 @@ _NOTE(CONSTCOND) } while (0) > > #ifndef CTASSERT > > #define CTASSERT(x) _CTASSERT(x, __LINE__) > > #define _CTASSERT(x, y) __CTASSERT(x, y) > > -#define __CTASSERT(x, y) \ > > - typedef char __compile_time_assertion__ ## y [(x) ? 1 : -1] > > +#define __CTASSERT(x, y) \ > > + _Static_assert((x), "Static assert failed at " #y) > > #endif > > > > #ifdef _KERNEL > > Note that the trick with the negatively indexed array is to support > older versions of gcc, which did not yet recognize _Static_assert. It > looks like this was added in gcc 4.6. > > -Dimitry > > sys/cdefs.h defines _Static_assert similarly on GCC 4.3-4.5, and defines it to nothingness on GCC-4.2. So we should be covered for all compilers that we care about. -Alan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2jg3JXEk9Wbq%2Bu_%2Bke%2BFGdL=8piRvGG_yC3ySnxHmXDiA>